Dealing with data transformation is a common task when working with various data formats and sources. In this blog post, we’ll show you how to easily convert XML to JSON in Azure Logic Apps without using Liquid templates. This simple yet effective method is perfect for handling XML documents or API responses that need processing in your Logic Apps.
Let’s use this generic XML response as an example:
<root> <element1> <!-- Your XML content here --> </element1> <element2> <!-- Your XML content here --> </element2> </root>
To convert this XML response to JSON, follow these steps:
First, use the xml() function to parse the XML content. Make sure you use the correct output from the previous action in your Logic App. In this example, it’s body(‘Your_Previous_Action_Name’)
xml(body('Your_Previous_Action_Name'))
Next, wrap the xml() function with the json() function to convert the parsed XML data into a JSON object
json(xml(body('Your_Previous_Action_Name')))
Finally, use the JSON object to access the desired values. In this example, we want the element1 and element2 nodes:
json(xml(body('Your_Previous_Action_Name')))['root']['element1'] json(xml(body('Your_Previous_Action_Name')))['root']['element2']
And that’s it! You’ve successfully converted generic XML data to JSON in Azure Logic Apps without using Liquid templates.
This easy-to-follow method allows you to streamline your XML to JSON conversion process in Azure Logic Apps. I hope that this blog post will help you save time and effort when working with various data formats and sources.
If you found this tutorial helpful, don’t forget to follow me on LinkedIn for more tips and tricks on Azure Logic Apps, integration, and other technical topics. Looking forward to connecting with you!
Legal Stuff