How to best convert an XML REST response into JSON?
Hello everyone,
I am getting an XML REST response and would like to push it onwards in JSON.
Can you advise on the best way to convert the XML input into a JSON output in Workato?
Cheers, Gabriel
Best Answer
B
Bryan Yap
said
about 6 years ago
Hi Gabriel, the best way to convert an XML input to JSON output would be to make use of Workato's XML Parser connector. This connector allows you to easily convert XML Strings to Workato Objects, which you can then convert to JSON Strings using the to_json function in formula mode. I've created an example recipe which you can refer to at https://www.workato.com/recipes/618288#recipe.
The key step in the recipe, i.e. the action which converts the XML String to a Workato Object can be seen in the screenshot below. Important point to take note is that sample document field within the XML Parser action should have more or less the same schema as the document itself. Any missing fields in the sample document would result in the corresponding missing data pills within the data tree.
Once the XML String has been parsed as an object, it can then be converted to a JSON String using the to_json function.
Answer
Bryan Yap
said
about 6 years ago
Hi Gabriel, the best way to convert an XML input to JSON output would be to make use of Workato's XML Parser connector. This connector allows you to easily convert XML Strings to Workato Objects, which you can then convert to JSON Strings using the to_json function in formula mode. I've created an example recipe which you can refer to at https://www.workato.com/recipes/618288#recipe.
The key step in the recipe, i.e. the action which converts the XML String to a Workato Object can be seen in the screenshot below. Important point to take note is that sample document field within the XML Parser action should have more or less the same schema as the document itself. Any missing fields in the sample document would result in the corresponding missing data pills within the data tree.
Once the XML String has been parsed as an object, it can then be converted to a JSON String using the to_json function.
Gabriel Burgener
How to best convert an XML REST response into JSON?
Hello everyone,
I am getting an XML REST response and would like to push it onwards in JSON.
Can you advise on the best way to convert the XML input into a JSON output in Workato?
Cheers, Gabriel
Hi Gabriel, the best way to convert an XML input to JSON output would be to make use of Workato's XML Parser connector. This connector allows you to easily convert XML Strings to Workato Objects, which you can then convert to JSON Strings using the to_json function in formula mode. I've created an example recipe which you can refer to at https://www.workato.com/recipes/618288#recipe.
The key step in the recipe, i.e. the action which converts the XML String to a Workato Object can be seen in the screenshot below. Important point to take note is that sample document field within the XML Parser action should have more or less the same schema as the document itself. Any missing fields in the sample document would result in the corresponding missing data pills within the data tree.

Once the XML String has been parsed as an object, it can then be converted to a JSON String using the to_json function.Bryan Yap
Hi Gabriel, the best way to convert an XML input to JSON output would be to make use of Workato's XML Parser connector. This connector allows you to easily convert XML Strings to Workato Objects, which you can then convert to JSON Strings using the to_json function in formula mode. I've created an example recipe which you can refer to at https://www.workato.com/recipes/618288#recipe.
The key step in the recipe, i.e. the action which converts the XML String to a Workato Object can be seen in the screenshot below. Important point to take note is that sample document field within the XML Parser action should have more or less the same schema as the document itself. Any missing fields in the sample document would result in the corresponding missing data pills within the data tree.

Once the XML String has been parsed as an object, it can then be converted to a JSON String using the to_json function.