Logic Apps Liquid maps: is the sort filter supported?

707 Views Asked by At

I'm trying to use a Liquid map in a Logic App to sort a incoming JSON. My incoming JSON is as follow:

{
 "content":
  [ 
    {
        "Identifier":"1",
        "Name":"B"
    },
    {
        "Identifier":"2",
        "Name":"A"
    }
  ]
 }

My Liquid map is as follow:

{
    {% assign sortedProfiles = content | sort: "Name" %}

    "Users":[
        {% for profile in sortedProfiles %}
        {
            "Identifier":"{{ profile.Identifier }}",
            "Name":"{{ profile.Name }}"
        },
        {% endfor %}]
}

Unfortunately, the array is never sorted by the name. I tried to use sort with an uppercase, I also tried to do the sort into the for, but none of those is working. I'm not sure if all filters are supported in Liquid maps for Logic Apps today, maybe the sort is not supported?

Thanks.

1

There are 1 best solutions below

0
On

The filter Sort works. If you use the next Liquid map:

{
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | Split: ", " %}

{% assign sort_my_array = (my_array | Sort ) %}

"Animals": [
    {% for animal in sort_my_array %}
    {
        "Name": "{{animal}}"
    },
    {% endfor %}
]       }

It returns:

{    
"Animals": [
    {
        "Name": "giraffe"
    },
    {
        "Name": "octopus"
    },
    {
        "Name": "Sally Snake"
    },
    {
        "Name": "zebra"
    }
]}

The problem seems that doesn't work with the sort of an array by a property.