I wish to get most recent collection from my json array based on created date in logic app variable or using dot liquid transformation.
{
"content": [
{
"properties": {
"id": "957777746054",
"owner": "jFinder",
"created": "2021-03-30T04:12:18+0000",
"updated": "2021-03-30T04:12:18+0000",
"revision": "1"
}
},
{
"properties": {
"id": "957777725902",
"owner": "jFinder",
"created": "2021-03-29T16:50:21+0000",
"updated": "2021-03-29T16:50:21+0000",
"revision": "1"
}
}
]
}
My idea was to sort this by "created" and then iterate over to pick first/last. But sort logic is not working. Can you help?
My liquid map start with
{% assign current = content.properties | Sort: "created" %}
{%- for item in current %}{"id" : "{{ current.id }}",do whatever} {%- endfor -%}
this always returns nill. I replaced created with id to see if that works but also didnt help



My answer is half baked and this is untested, but I think you have your liquid a little confused. I think it should look like this ...
Your array is contained within the
contentproperty which means you should be looping over that and then referencing lower level, sub properties through thepropertyproperty.Now, if that doesn't work, my suggestion would be to look at using the
Advanced Data Operationsconnector. There's an operation there called Sort Object Array ...... and it takes in an array of complex objects and will sort it based on your instructions.
Documentation can be found here ... https://www.statesolutions.com.au/sort-object-array/
So in relation to your requirement, this flow demonstrates the usage ...
I loaded your data in to a variable called Data and then in the next step, I refer to the underlying
Contentarray and then sort it byproperties.createdin an ascending order.It's a little bit hard to show in a single screenshot but you can see it's ordered it as instructed to ...