azureazure-logic-apps

how to create new json object using compose connector in logic app without change in order?


In my logic app, I have used the compose connector. After saving it, the output is in asc order

How can I maintain the order I specified in the compose connector?

The original json is -

{
"mainId":"2323",
"address":"DC"
}

But after saving, the order is:

{
"address":"DC",
"mainId":"2323"
}

Solution

  • If you just compose the data, it will show asc order cause JavaScript JSON libraries default to alphabetical ordering of properties. So this is an expected behaviour that shouldn't have side effects if you stick to the JSON format. In other scenarios, like converting to XML.

    If you insist on the custom order you could try with my. I create the json format string then compose it or parse it to json.

    enter image description here

    enter image description here

    You could try compose or parse json action, they all could work. Hope this could help you.