I am building a logic app where I have some JSON pulled from Shopify this has extended properties like this
{
"metafields": [
{
"id": 222222,
"namespace": "global",
"key": "test",
"value": "210690"
},
{
"id": 555555,
"namespace": "custom",
"key": "pallet_quantity",
"value": 2
}
]
}
I can use an expression like this:
body('Parse_VariantMetaJSON')?['metafields'][0]['value']
to get me the value of the object with a name of test however from my testing it is not always 0 and if its empty and a different field is populated that becomes 0.
Can I target this with an expression that identifies using the value of key? I have tried this
first(body('Parse_VariantMetaJSON')?['metafields'][?(@['key'] == 'test')])?['value']
But the logic app always states that it is an invalid expression.
I think the simplest way would be to use the Filter array
operation.
It’s by far the easiest way to target the item you are wanting to retrieve.
It will make your flow a little more verbose but it does the job.