0

How do I create a JSON collection based on the Compose actions of the for each mentioned below? If I add a comma after the "}" it will be one too many at the end. Secondly, I somehow need to wrap it in a collection [ ]

I have a Foreach which has a Compose (iteration 1):

{
    "Name": "A"
    "Value": "1"
}

Second Compose contains another object (iteration 2)

{
    "Name": "B"
    "Value": "2"
}

However, I now do want to merge these composes to:

"CollectionName": [{
        "Name": "A"
        "Value": "1"
    },
    {
        "Name": "B"
        "Value": "2"
    },
    {
        "Name": "C"
        "Value": "3"
    }
]
Jay
  • 189
  • 4
  • 12

1 Answers1

1

You can use union

union('<collection1>', '<collection2>', ...)
union([<collection1>], [<collection2>], ...)

You can refer to Combine two JSON Arrays to one and How can I merge the outputs from a For_Each loop in an Azure Logic App to a single flat array?

Ecstasy
  • 1,866
  • 1
  • 9
  • 17