I am working in MS Power Automate (Flow) and I want to filter a JSON array by a string to retrieve the value...
here is a subset of my JSON Data (this data has been extracted from a SharePoint list by a Flow Get Items step):
[
{
"@odata.etag": "\"2\"",
"ItemInternalId": "1",
"ID": 1,
"Setting1": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "Email Addresses"
},
"Setting1#Id": 0,
"Setting2": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "Retail Marketing Team Email"
},
"Setting2#Id": 0,
"Value1": "person1@company.co.uk; person2@company.co.uk; "
},
{
"@odata.etag": "\"2\"",
"ItemInternalId": "2",
"ID": 2,
"Setting1": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "Email Addresses"
},
"Setting1#Id": 0,
"Setting2": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 1,
"Value": "Social Media Email"
},
"Setting2#Id": 1,
"Value1": "paidsocial@company.co.uk; person3@company.co.uk; person4@company.co.uk;"
},
....
]
I need to filter that on the field Setting2 = "search string", and return Value1 by matching a string
So, for Setting2 I would use 'Retail Marketing Team Email' and extract the value of the Value1 field which is '*person1@company.co.uk; person2@company.co.uk; *'
Now, with $..['Value1']
I can get all of the Value1 values, and with filtering I should be able to retrieve a specific Value1 element...
I have tried this:
$.[?(@.Setting2 == 'Retail Marketing Team Email')]['Value1']
and
$..['Setting2'].['Value' == 'Retail Marketing Team Email']?['Value']
and several other variations but never seem to get any data back, or OI get a JSON Parse error
what is the right way to go about this?