Updated : 09/10/2018
A couple of months ago, I was conducting an Transformation Extender workshop with a financial customer in Europe. They had a use case where they were using the response from a restful service call during their processing, and had asked about using the JSON importer to generate the type trees they needed when dealing with the RESTFUL response. While the JSON importer will generate a proprietary type tree (mtt) representation of the JSON data, there is a much simpler approach when you do not need the additional validation capability that exists in the mtt. We will discuss the simpler approach in a moment.
If you remember the “good ole days” when Mercator first introduced XML importers, we would import DTD’s and XSD’s to generate mtt files to use with maps. If you remember importing XML definitions, you also recall the complexity of the type trees generated by that process. Later, when the concept of using native XSD as the “Type Tree” was introduced, shouts of joy could be heard throughout the Mercator user community, because mapping to and from XML just became less complex.
Using the JSON importer to generate mtt files to use for mapping, generates a complex type tree, just as importing DTD and XSD did. Below is a picture of a card defined using mtt file generated using the document Currencies.JSON.
Looking at the next picture, makes it clear that native use of Currencies.JSON to define the card will simplify mapping, when compared to using the mtt file generated from the same JSON document, just as using native XSD made mapping more simple for XML.
To further illustrate the example, I included the pictures below. The picture on the left shows the file Currencies.JSON. This is the same file used to generate the type tree mentioned above, that was used to define the card in the first picture. The same file was used to define the card in the second picture in this article, but it was referenced directly. This is the same picture that immediately precedes this paragraph.
In my opinion, it is clear which representation of the JSON data would be easier to map?
WARNING: When using a JSON document to define a card, you ALWAYS pick the root element for the type as depicted in the picture on the right below.
JSON is everywhere, so define your cards the easy way, use your sample data and you are ready to map. No type trees necessary. Happy mapping.
HCL Products & Platforms
Transformation Extender is a trademark of IBM Corporation in at least one jurisdiction and is used under license.