1. JSON to JSON Transformation
Input JSON
{
"name": "John Doe",
"age": 30,
"address": {
"city": "New York",
"country": "USA"
}
}
Liquid Template (json-to-json.liquid
)
{
"fullName": "{{ content.name }}",
"yearsOld": {{ content.age }},
"location": {
"city": "{{ content.address.city }}",
"country": "{{ content.address.country }}"
}
}
Output JSON
{
"fullName": "John Doe",
"yearsOld": 30,
"location": {
"city": "New York",
"country": "USA"
}
}
Steps in Azure Logic Apps
- Add a Transform JSON to JSON action.
- Upload the
json-to-json.liquid
template in Integration Account under map section. - Map the input JSON to the template.
- Run the workflow to see the transformed JSON.
2. JSON to TEXT Transformation
Input JSON
{
"name": "Jane Smith",
"age": 25,
"address": {
"city": "London",
"country": "UK"
}
}
Liquid Template (json-to-text.liquid
)
Name: {{ content.name }}
Age: {{ content.age }}
City: {{ content.address.city }}
Country: {{ content.address.country }}
Output TEXT
Name: Jane Smith
Age: 25
City: London
Country: UK
Steps in Azure Logic Apps
- Add a Transform JSON to TEXT action.
- Upload the
json-to-text.liquid
template in Integration Account under map section. - Map the input JSON to the template.
- Run the workflow to see the transformed TEXT.
3. XML to JSON Transformation
Input XML
<root>
<name>John Doe</name>
<age>30</age>
<address>
<city>New York</city>
<country>USA</country>
</address>
</root>
Liquid Template (xml-to-json.liquid
)
{
"fullName": "{{ content.root.name }}",
"yearsOld": {{ content.root.age }},
"location": {
"city": "{{ content.root.address.city }}",
"country": "{{ content.root.address.country }}"
}
}
Output JSON
{
"fullName": "John Doe",
"yearsOld": 30,
"location": {
"city": "New York",
"country": "USA"
}
}
Steps in Azure Logic Apps
- Add a Transform XML to JSON action.
- Upload the
xml-to-json.liquid
template in Integration Account under map section. - Map the input XML to the template.
- Run the workflow to see the transformed JSON.
4. XML to TEXT Transformation
Input XML
<root>
<name>Jane Smith</name>
<age>25</age>
<address>
<city>London</city>
<country>UK</country>
</address>
</root>
Liquid Template (xml-to-text.liquid
)
Name: {{ content.root.name }}
Age: {{ content.root.age }}
City: {{ content.root.address.city }}
Country: {{ content.root.address.country }}
Output TEXT
Name: Jane Smith
Age: 25
City: London
Country: UK
Steps in Azure Logic Apps
- Add a Transform XML to TEXT action.
- Upload the
xml-to-text.liquid
template in Integration Account under map section. - Map the input XML to the template.
- Run the workflow to see the transformed TEXT.
How to Set Up in Azure Logic Apps
- Create a Logic App:
- Go to the Azure portal and create a new Logic App.
- Add a Trigger:
- Use an HTTP request trigger or any other trigger to start the workflow.
- Add Transformation Actions:
- For JSON transformations: Use the Transform JSON to JSON or Transform JSON to TEXT action.
- For XML transformations: Use the Transform XML to JSON or Transform XML to TEXT action.
- Upload Liquid Templates:
- Go to the Integration Account in Azure and upload your
.liquid
files. - Link the templates to the transformation actions in your Logic App.
- Map Input Data:
- Provide the input JSON or XML data to the transformation action.
- Test and Run:
- Run the workflow and verify the output.
Sample Workflow
- Trigger: HTTP request with JSON or XML payload.
- Action: Transform JSON/XML to JSON/TEXT using a Liquid template.
- Output: Send the transformed data to another system or store it.