JSON to JSON Transformation using Azure Logic Apps and Liquid

Posted On October 18, 2024 by Deepak Chauhan Posted in  Tagged in

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. 
 
                                 

A screenshot of a computer

Description automatically generated

 

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: 

  1. A Free Tier Azure Integration Account 
  1. A Consumption Tier Azure Logic App 
  1. 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 

  1. Log in to the Azure portal. 
  1. Navigate to the Integration Account section. 
  1. Create a Free Tier Integration Account. 

Step 2: Add the Liquid Template Map 

  1. In the Integration Account, select Maps from the left menu. 
  1. Click + Add to upload a new map. 
  1. Select Liquid as the map type and upload your Liquid template file (with a .liquid extension). 
     
    A screenshot of a computer

Description automatically generated 

Step 3: Create a Logic App 

  1. In the Azure portal, create a Logic App. 
  1. Add the trigger When an HTTP request is received. Set it up as a POST request to receive the incoming JSON. 
     
    A screenshot of a computer

Description automatically generated 

Step 4: Transform JSON to JSON using Liquid 

  1. In the Logic App workflow, add the action Transform JSON to JSON. 
  1. 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}}” 


 

A screenshot of a computer

Description automatically generated

 

Step 5: Test with Postman 

  1. Use Postman or another API testing tool to send a POST request to your Logic App with the input JSON. 
  1. 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]


Share Story :

Secured By miniOrange