I'm working on power automate and I have an issue because I've tried a lot expressions and none of them working.
I did a loop (foreach) and inside a message (compose) and there I tried to display "f7626790-0756-43bf-a757-a645a33b853d" from"client"
To do so, I've tried all those expressions:
- item()?['client']
- item()?['client']?[0]
- item()['client']
Here my json file:
[
{
"gift": [
{
"client": "f7626790-0756-43bf-a757-a645a33b853d",
"details": [
{
"client_id": 10859085,
"type": "christmas",
"application_id": "6e6d758d-8e74-3ae3-ac84-50eb23ae65f"
}
]
}
]
}
]
Thank's in advance.
CodePudding user response:
Based on the JSON you provided, you have two arrays. So the question for me is, which array do you want to iterate? Both or the inner one?
I'm going to assume both or if not, it won't matter if you only ever have one item for both of them, my answer will still retrieve the client property.
The
Initialize Datastep has your JSON.The
Initialize Clientstep is a blank string at this stage.The
For Each Outer Itemexpression is simply a link to theDatavariable as initialized in the first step.The
For Each Giftexpression is set as ...item()?['gift']... as you can work out, that will loop over eachgiftitem.Finally, I get the value of the
clientproperty using this expression ...item()['client']


