Let us consider a sample JSON file, which provides Customer-Address details, to explain how JSON Target Connector works.
JSON Target Connector is based on the following principles:
•The XPaths are the building blocks of JSON Target Connector.
•JSON Target Connector parses the JSON file and generates the XPaths of each JSON object or JSON array.
•JSON Target Connector uses the XPaths to generate XML file with adequate primary and foreign key relationships.
•The XMLStreamReader and XMLStreamWriter cleans the generated XML file.
•The cleaned XML file is transformed into a valid JSON file based on the SAXevent parsing approach.
The following figure shows a sample JSON file of Customer - Address details.
JSON Target Connector follows the following principles to group elements into tables or fields:
•JSON file must have root element. When the JSON file does not contain any root element, then the connector creates a dummy root called JSONRoot. The root element is used for further processing of files.
•All the simple and attribute elements are considered as fields. Complex elements are not considered as fields.
•Unbound elements are segregated and considered as separate tables.
•Any bound element to the former element becomes the child element of the former element.
Based on the sample file shown in the above figure, the following tables are created:
- Table-1: JsonRoot with XPath/JsonRoot
- Table-2: Customers_Customer_Address with XPath/Customers/Customer/Address
The following figure shows the tables written to the target: