我有这样的 JSON:
{
"dcsId": "1184001100000000517",
"marketCode": "US",
"languageCode": "en-US",
"profile": {
"base": {
"username": "arunima27",
"activeInd": "R",
"phone": [
{
"activeInd": "Y",
"type": "mobile",
"primaryInd": "Y",
"number": "2234566788"
},
{
"activeInd": "N",
"type": "mobile",
"primaryInd": "N",
"number": ""
}
]
}
}
}
从这个输入 JSON 中,我们需要提取有效负载.profile.base.phone.number,其中有效负载.profile.base.phone.type ==“mobile”和有效负载.profile.base.phone.activeInd ==“Y”。实际上,我们需要循环遍历 JSON 数组 (payload.profile.base.*phone) 并仅获取处于活动状态且类别/类型为移动的电话号码。
我们需要如下输出:
{
"dcsId": "1184001100000000517",
"marketCode": "US",
"languageCode": "en-US",
"username" : "arunima27",
"phoneNumber" : "2234566788"
}
我们在对“phoneNumber”输出变量进行此转换时遇到问题。