根据我的理解,您只想循环数组来获取每个项目的名称、邮件和其他一些字段。正如您在问题中提到的,您可以使用 json 正文作为 For Each 循环的输入。没关系,不需要再做什么了。请参考下面的截图:
Initialize a variable like your json data.
![enter image description here](https://i.stack.imgur.com/0Rf9N.png)
Then parse it by "Parse JSON" action.
![enter image description here](https://i.stack.imgur.com/4mFyR.png)
Now, set the body as input for the For each loop, and then use a variable and set the value with "mail" from "Parse JSON".
![enter image description here](https://i.stack.imgur.com/DS1zh.png)
After running the logic app, we can see the mail field is also looped. You can use the "mail", "name" and other fields easily in your "For each".
![enter image description here](https://i.stack.imgur.com/km2pM.png)
Update:
I checked your json schema, but it seems can't match the json data you provided in your screenshot. May I know how did you generate your json schema, in my side I generate the json schema just by clicking the "Use sample payload to generate schema" button and it will generate the schema automatically.
![enter image description here](https://i.stack.imgur.com/VEU5v.png)
我使用了一个与你的结构相同的json数据样本并生成了它的schema,请参考下面的json数据和schema:
json数据:
{
"body": [
{
"@odata.type": "test",
"id": "123456",
"givenName": "test",
"username": "test",
"userPrincipalName": "test",
"mail": "[email protected] /cdn-cgi/l/email-protection",
"onPremisesSamAccountName": "test",
"employeeId": "test",
"createdDateTime": "testdate"
},
{
"@odata.type": "test",
"id": "123456",
"givenName": "test",
"username": "test",
"userPrincipalName": "test",
"mail": "[email protected] /cdn-cgi/l/email-protection",
"onPremisesSamAccountName": "test",
"employeeId": "test",
"createdDateTime": "testdate"
}
]
}
schema:
{
"type": "object",
"properties": {
"body": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@@odata.type": {
"type": "string"
},
"id": {
"type": "string"
},
"givenName": {
"type": "string"
},
"username": {
"type": "string"
},
"userPrincipalName": {
"type": "string"
},
"mail": {
"type": "string"
},
"onPremisesSamAccountName": {
"type": "string"
},
"employeeId": {
"type": "string"
},
"createdDateTime": {
"type": "string"
}
},
"required": [
"@@odata.type",
"id",
"givenName",
"username",
"userPrincipalName",
"mail",
"onPremisesSamAccountName",
"employeeId",
"createdDateTime"
]
}
}
}
}