HomeAbout Me

Easily Convert XML to JSON in Azure Logic Apps Without Liquid Templates

By Sri Gunnala
Published in Microsoft Azure
April 07, 2023
1 min read
Easily Convert XML to JSON in Azure Logic Apps Without Liquid Templates

Introduction

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.

Step-by-Step: Converting XML to JSON

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:

Step 1: Parse the XML Content

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'))

Step 2: Convert Parsed XML Data into a JSON Object

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')))

Step 3: Access the Desired JSON Values

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.

Conclusion

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!


Tags

#Azure#AzureLogicApps
Previous Article
Ingest JSON Array data into Azure Data Explorer (ADX) using .NET SDK & Azure Functions
Sri Gunnala

Sri Gunnala

Learner | Reader | Blogger | Azure Enthusiast

Topics

Front End
Microsoft Azure
Microsoft .NET

Newsletter

Sri Gunnala - Make sure to subscribe to newsletter and be the first to know the news.

Related Posts

Azure APIM Caching Policy | Cache-lookup Policy | HTTP GET | Non-Cache HTTP POST
September 21, 2024
2 min

Legal Stuff

Privacy NoticeCookie PolicyTerms Of Use

Social Media