The JSON connector in Zynk contains tasks that allow you to convert JSON files to and from XML. This is useful when integrating with JSON files, as the majority of the tasks in Zynk expect their input and output files to be in XML format. This tutorial demonstrates how to use the tasks in the JSON library, by taking a JSON file, converting it to XML, and then converting it back to JSON again.
You can download a copy of the sample workflow and JSON file here.
JSON to XML
This task takes the customers_in.json file, and converts it to XML. The task settings are configured as follows:
- Root Element Name - This is set to ‘Customers’, as the JSON input file does not contain a single root. This setting is required as XML files must always contain one root node. If the JSON file did contain a single root, this setting could have been left blank, and the task would have just used the root from the JSON file.
- Input File - This is set to ‘customers_in.json’, and is the JSON file we want to convert to XML.
- Output File - This is set to ‘customers.xml’, this is the file the resulting XML will be saved to.
XML to JSON
This task takes the customers.xml file generated by the previous task, and converts it back to JSON. The task settings are configured as follows:
- Omit Root Object - This is set to ‘True’, as we created our own root node ‘Customers’ in the XML file, which wasn’t part of the original JSON file, so we want to omit it when converting the XML back to JSON.
- Input File - This is set to ‘customers.xml’, and is the XML file we want to convert to JSON.
- Output File - This is set to ‘customers_out.json’, this is the file the resulting JSON will be saved to.
If you have any queries on any of the above, feel free to contact our support team via email at email@example.com or via telephone on 0191 303 7279. Please note, as stated on the Auto Mapper task we do not support any changes to XSLT.
Back | Edit on Github