我想遍历每个对象,并用system.myStringValue
映射value.myStringValue
您可以提供相同的规格吗?
我提供了以下输入和输出json。如果有其他需要我支持的事情,请告诉我。我尝试使用另一种规格,但是它对我不起作用,因为我想将电子邮件和电话结合在一个对象中
输入:
[
{
"telecom": [
{
"system": {
"myStringValue": "email"
},
"value": {
"myStringValue": "mobqa@tester.com"
}
},
{
"system": {
"myStringValue": "phone"
},
"value": {
"myStringValue": "123"
}
}
]
},
{
"telecom": [
{
"system": {
"myStringValue": "email"
},
"value": {
"myStringValue": "john.doe@tester.com"
}
}
]
},
{
"telecom": [
{
"system": {
"myStringValue": "email"
},
"value": {
"myStringValue": "Gayle55@tester.com"
}
}
]
}
]
输出:
{
"users": [
{
"email":"mobqa@tester.com",
"phone":"123"
},
{
"email":"john.doe@tester.com"
},
{
"email":"Gayle55@tester.com"
}
]
}
答案 0 :(得分:-1)
[
{
"operation": "shift",
"spec": {
"*": {
"telecom": {
"*": {
"value": {
"myStringValue": {
// @ takes value of 'value.myStringValue' and puts it into 'users[&5]' occurence
// @(3,system.myStringValue) go up four levels and then go to 'system.myStringValue'
// value and grab it and put as key value to appropriate occurence of 'users'
"@": "users[&5].@(3,system.myStringValue)"
}
}
}
}
}
}
}
]