Transforming JSON TO CSV using Logic Apps and Liquid Templates
Brief about Liquid Templates
Created by Shopify, Liquid Templates have been a burning issue for transformations of object notation payloads like JSON, XML, CSV. The fluidity of liquid filters and tags makes the transformation dynamic and easy to achieve. Manipulating input with different filters serves as an essence of Liquid. The use of uncomplicated delimiters renders the content in desired format.
JSON Data Input
I have a requirement of creating a customized CSV (Comma separated value) file using a JSON input. For the demo purpose, I have the following json input.
To transform any input using liquid, a template has to be created. Liquid template represents a file with ‘.liquid’ extension. We write logic using liquid tags, iterations, filters that renders the content, transforming input file to output payload.
For the json input, that we are using, I have improvised a customization in person’s name. In the csv file, the name should be string comprising of first name, first letter of middle name and last name.
I have created following liquid template for required results.
Azure cloud provides a remarkable service to create automated workflows. Actions and triggers orchestrate tasks in a codeless and effortless way. There are connectors from Cloudmersive, Apptigent, and Microsoft to convert Json to Csv format. Creating a customized csv output can be done by liquid template.
Azure integration account stores B2B artifacts such as Maps, Schemas, Agreements, Certificates and Assemblies. The liquid template that we used, should be saved inside maps, as it be used to map the json to csv file.
Creating Logic Apps Workflow
Before creating the workflow, we have to go to workflow setting to add the integration account to logic app.
For this demo purpose, I have created a simple Http request-response model logic app with a Liquid connector and Azure Blob Storage connector. The action used for liquid connector is ‘Transform JSON to Text’. Blob storage connector uses ‘Create Blob’ action. Transformed content is saved to blob with a ‘filename.csv’ format. The workflow looks like-
I am using Postman Rest Api tool to send http request, which triggers the logic app. Json content is sent in the body of request. The Liquid connector action uses http trigger body content and a liquid map from integration account to transform input json to a text value in comma separated values format. We are saving the transformed output to blob storage with .csv file extension.
After request is processed, the logic app response is sent as the transformed output as below.
We can download the csv file rom blob storage to view the values in csv format.
As we can conclude, with Liquid templates, converting a Json content to Csv has become an easy feat. The appropriate use loops and filter tags results in desired output for JSON, XML and CSV formats.
Because of its dynamic nature, liquid templates are being used by numerous tech companies such as Jekyll, Salesforce, Desk, GoDaddy, Fedora, Lucid, Flipkart, InSales, Carnival and many more.
For more information about Liquid Templates, refer to following Link:
For more information about Azure Logic apps, refer to following Link:
For more information about Azure Integration Account, refer to following Link: