Reputation: 77
In Azure logic apps I am creating a Json body in compose action. JSON structure is like below I am passing place property value as an variable i.e. variables('result')
:
{
"place": [
{ "visit":"name"
},
{ "visit":"name"
}
]
}
In compose action how to get the above structure as i could not get the exact array like structure. I've tried a lot of things, but the result is like below:
{
"place": "[
{ "visit":"name"
},
{ "visit":"name"
}
]"
}
Double quotes are getting appended in the variable in compose action. If I pass as an array in compose means got like below double quotes is there in every element of array. I don't want doubles quotes inside array elements and I want the value as a variable in compose action's property:
{
"place": [
"{ "visit":"name"
}",
"{ "visit":"name"
}"
]
}
}
Please let me know hot to get the exact structure.
Upvotes: 0
Views: 10982
Reputation: 153
I'm assuming your result variable is of type array and contains the following value (you can check this in your run history):
[
"{\"visit\":\"London\"}",
"{\"visit\":\"Paris\"}"
]
Note that I created my result variable using an expression - createArray('{"visit":"London"}','{"visit":"Paris"}')
You can add a For each that takes the result variable as its input.
Within the For each you can include a Parse JSON action that takes Current item as the Content. You will need to provide the schema of your array objects also.
{
"type": "object",
"properties": {
"visit": {
"type": "string"
}
}
}
Outside of the For each loop you can then create a Compose action. The code view for the Compose action looks like this.
{
"inputs": {
"place": "@actionBody('Parse_JSON')"
}
}
The output from this is the following:
{
"place": [
{
"visit": "London"
},
{
"visit": "Paris"
}
]
}
Upvotes: 1