我正在使用MS Power Automate(Flow),并且想通过字符串过滤JSON数组以检索值...
这是我的JSON数据的子集(此数据已通过流程获取项目步骤从SharePoint列表中提取):
[
{
"@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;"
},
....
]
我需要在字段 Setting2 =“搜索字符串”上进行过滤,并通过匹配字符串返回 Value1
因此,对于 Setting2 ,我将使用'零售营销团队电子邮件',并提取 Value1 字段的值为'* person1 @ company.co.uk; person2@company.co.uk; *'
现在,使用$..['Value1']
我可以获取所有 Value1 值,并且通过过滤,我应该能够检索特定的 Value1 元素...
我已经尝试过了:
$.[?(@.Setting2 == 'Retail Marketing Team Email')]['Value1']
和
$..['Setting2'].['Value' == 'Retail Marketing Team Email']?['Value']
和其他几种变体,但似乎从未恢复任何数据,否则OI会收到JSON Parse错误
什么是正确的方法?