JSON to JSON Transformation using Azure Logic Apps and Liquid
Introduction
In this blog post, I’ll walk you through the process of transforming JSON to JSON using Azure Logic Apps and the Liquid Template Language. This step-by-step guide will demonstrate how you can use Azure Integration Services to achieve your transformation goals.
What is Liquid Template Language?
The Liquid Template Language (commonly referred to as “Liquid”) is a flexible, open-source template language developed by Shopify. It is widely used to render dynamic content in platforms such as Shopify themes, Jekyll websites, and web applications. Liquid uses placeholders, loops, and conditional statements to pull dynamic data into a web template, making it an effective tool for JSON transformation.
Prerequisites
To complete this tutorial, you’ll need:
- A Free Tier Azure Integration Account
- A Consumption Tier Azure Logic App
- Postman or a similar API testing tool for sending HTTP requests
Sample Input JSON
We will use the following sample JSON file for this tutorial:
{
“FirstName”: “Deepak”,
“LastName”: “Ch”,
“Add1”: “T square, Saki Vihar Road, Andheri East”,
“Add2”: “Mumbai”,
“Landmark”: “Near Car Showroom”,
“PhoneNo1”: 9812727261,
“PhoneNo2”: 2121233322
}
Desired Output JSON
The client’s requirement is to transform the input JSON into the following format:
{
“Full Name”: “Deepak Ch”,
“Address”: “T square, Saki Vihar Road, Andheri East, Mumbai, Near Car Showroom”,
“Phone”: “9812727261, 2121233322”
}
Step-by-Step Guide –
Step 1: Create a Free Azure Integration Account
- Log in to the Azure portal.
- Navigate to the Integration Account section.
- Create a Free Tier Integration Account.
Step 2: Add the Liquid Template Map
- In the Integration Account, select Maps from the left menu.
- Click + Add to upload a new map.
- Select Liquid as the map type and upload your Liquid template file (with a .liquid extension).
Step 3: Create a Logic App
- In the Azure portal, create a Logic App.
- Add the trigger When an HTTP request is received. Set it up as a POST request to receive the incoming JSON.
Step 4: Transform JSON to JSON using Liquid
- In the Logic App workflow, add the action Transform JSON to JSON.
- In the action settings, select the Liquid template that you uploaded earlier.
Here’s the Liquid template used for this transformation:
{
“Full Name”: “{{content.FirstName}} {{content.LastName}}”,
“Address”: “{{content.Add1}}, {{content.Add2}}, {{content.Landmark}}”,
“Phone”: “{{content.PhoneNo1}}, {{content.PhoneNo2}}”
}
Step 5: Test with Postman
- Use Postman or another API testing tool to send a POST request to your Logic App with the input JSON.
- Upon execution, the output JSON should appear in the desired format.
Final Output
The output JSON will be:
{
“Full Name”: “Deepak Ch”,
“Address”: “T square, Saki Vihar Road, Andheri East, Mumbai, Near Car Showroom”,
“Phone”: “9812727261, 2121233322”
}
We hope you found this article useful, and if you would like to discuss anything, you can reach out to us at [email protected]