简体   繁体   中英

Query a JSON object in Powerautomate

In Power Automate I have a JSON object like this (this is a small sample, the actual bigger):

{
    "items": [
        {
            "day": 1,
            "month": 1,
            "year": 2021,
            "balance": 6
        },
        {
            "day": 2,
            "month": 1,
            "year": 2021,
            "balance": 47
        }
   ]
}

Additionally, I have a variable with a specific day (myDay), I want to get the value of the balance for the day = myDay, how can I achieve this?

What is the syntax to use instead of a fixed value (variables('myJson')?['items']?[1]?['balance'])?

Thanks,

Considering the additional details in the comments, I think this expression should do the trick:

variables('myJson')?['items']?[sub(variables('myDay'), 1)]?['balance']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM