azureazure-logic-appsdotliquidazure-logic-app-standard

dotLiquid template for Azure Logic Apps' SQL Execute Query output


Azure Logic Apps' SQL Execute Query action returns JSON output like this:

[
  [
    {
      "ProductID": 7000,
      "ProductName": "Some name"
    },
    ...
  ]
]

What syntax would be correct to use with dotLiquid in the Azure Logic Apps JSON to JSON transform action to iterate over those nested arrays to get rid of the nesting, for example to generate something like this:

{
  "products": [
    {
      "productId": 7000,
      "productName": "Some name"
    },
    ...
  ]
}

Solution

  • After continued trial-and-error, I arrived at this solution:

    {
        "products": [
            {% for product in content[0] %}
            {
                "productId": {{ product.ProductID }}
            }{% unless forloop.last %},{% endunless %}
            {% endfor %}
        ]
    }