我在处理JSON文档中另一个数组中的嵌套数组时遇到了问题。我需要获取一个包含一个JSON文档的数组,该文档具有"CandidateEmail"和"ApplicationId""JobRefNumber"。我认为下面的示例将帮助您更好地理解。
我的意见是:
{
"Content": [
{
"CandidateEmail": "john1@noexist.com",
"Applications": [
{
"ApplicationId": "app1",
"JobRefNumber": "REF1"
},
{
"ApplicationId": "app2",
"JobRefNumber": "REF2"
}
]
},
{
"CandidateEmail": "carl2@email.com",
"Applications": [
{
"ApplicationId": "app3",
"JobRefNumber": "REF3"
},
{
"ApplicationId": "app4",
"JobRefNumber": "REF4"
}
]
}
]
}
预期输出为:
[
{
"CandidateEmail": "john1@noexist.com",
"ApplicationId": "app1",
"JobRefNumber": "REF1"
},
{
"CandidateEmail": "john1@noexist.com",
"ApplicationId": "app2",
"JobRefNumber": "REF2"
},
{
"CandidateEmail": "carl2@email.com",
"ApplicationId": "app3",
"JobRefNumber": "REF3"
},
{
"CandidateEmail": "carl2@email.com",
"ApplicationId": "app4",
"JobRefNumber": "REF4"
}
]
我不知道它是否会有任何帮助,但这里是我到目前为止能够起草的规范:
[
{
"operation": "shift",
"spec": {
"Content": {
"*": {
"Applications": {
"*": {
"@(2,CandidateEmail)": "[&1].CandidateEmail",
"ApplicationId": "[&1].ApplicationId",
"JobRefNumber": "[&1].JobRefNumber"
}
}
}
}
}
}
]
1条答案
按热度按时间62lalag41#
您可以使用shift转换规范,例如