Can we access parsed JSON key using logic app variable?
I have a string type variable with value as FY23-01 like below:
And a parsed JSON like below:
{
"@odata.etag": "",
"FY23-01": "1",
"FY23-02": "2",
"FY23-03": "3",
"FY23-04": "4",
}
Now I want to get the value of key "FY23-01". I am using below expression and it always returns blank:
body('Parse_JSON')?[variables('secondContent')]
Is it supported to use variables in key reference for JSON?
Yes it is supported to use variables in key reference for JSON.
The expression
body('Parse_JSON')?[variables('secondContent')]
should work to access the value from Json.
One of the alternative approach is using this expression outputs('Parse_Json')?['body']?[variables('secondContent')]
. I have tried in both the ways and below are steps I followed,
outputs('Parse_Json')?['body']?[variables('secondContent')]
,
body('Parse_JSON')?[variables('secondContent')]
, this also worked and got result.