Logic Apps - Sort json

Andoni Aguirre 45 Reputation points
2023-09-18T15:00:18.6266667+00:00

Hello,

I need to sort this json by the "exp" key, ascending. How can I do this? Standard sort() function does not do the jobUser's image

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,551 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,941 Reputation points Moderator
    2023-09-18T16:50:49.9+00:00

    @Anonymous Thanks for reaching out. Sort method would have helped in scenario when your property is not the nested JSON object.

    For example, if your json would be below and you want to sort it with the property ex then you would have used the

    sort(body('Parse_JSON'),'exp') but this doesn't work with the nested json object properties.

    [
      {
        "ex": "2023-09-20",
        "attributes": {
          "enabled": true,
          "exp": "2023-09-20"
        },
        "id": "1",
        "tags": {
          "owner": "test"
        }
      },
      {
       "ex": "2023-09-19",
        "attributes": {
          "enabled": true,
          "exp": "2023-09-19"
        },
        "id": "2",
        "tags": {
          "owner": "test"
        }
      },
      {
      "ex": "2023-09-18",
        "attributes": {
          "enabled": true,
          "exp": "2023-09-18"
        },
        "id": "3",
        "tags": {
          "owner": "test"
        }
      }
    ]
    

    The workaround would be leveraging the liquid template or use the inline code to sort it as per your need.

    Let me know if you have any queries or concerns.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.