• Documentation
  • Workato Blog
  • Product Blog
  • Return to Workato
  • Login
  • Automation Institute
  • Documentation
  • Community Forums
New Topic
Discussions Recipe Building Recipe Building Questions

Gabriel Burgener

started a topic over 5 years ago
Answered

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 over 5 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.

image

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

image


Answer

Bryan Yap

said over 5 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.

image

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

image


Login to post a comment

Still can't find your solution?

Send us a ticket, we will try our best to assist you with your problem

Documentation
Developer's Library
Tutorials
eBooks
Product Hour
Product Blog
Workato Blog
Product updates
Customer Stories
© Workato 2022   Privacy   Terms   +1 (844) 469-6752
  • Documentation
  • Workato Blog
  • Product Blog
  • Solutions
  • Forums
  • Tickets
  • Log in
  • Return to Workato
Topic views count