[英]Using Jolt for json transformation :
I'm expecting the format of Input and output json will be same with one field modification ie name to firstname.我期望 Input 和 output json 的格式将与一个字段修改相同,即名称到名字。 Further leads would be appreciated.进一步的线索将不胜感激。 Thanks in Advance提前致谢
Input Json:输入 Json:
[
{
"id": 123,
"name": "Pankaj Kumar",
"permanent": true,
"address": {
"street": "El Camino Real",
"city": "San Jose",
"zipcode": 95014
},
"phoneNumbers": [
9988664422,
1234567890
],
"role": "Developer"
},
{
"id": 124,
"name": "Rahul Dravid",
"permanent": false,
"address": {
"street": "Baner",
"city": "Pune",
"zipcode": 95014
},
"phoneNumbers": [
9988664422,
1234567890
],
"role": "Product owner"
}
]
Spec json:规格 json:
[
{
"operation": "default",
"spec": {
"*": {
"id": "id",
"name": "firstname",
"permanent": "permanent",
"address": "Employee address",
"phoneNumbers": "phoneNumbers",
"role": "role",
"fname": "fname"
}
}
}
]
Output json: Output json:
[ {
"id" : 123,
"name" : "Pankaj Kumar",
"permanent" : true,
"address" : {
"street" : "El Camino Real",
"city" : "San Jose",
"zipcode" : 95014
},
"phoneNumbers" : [ 9988664422, 1234567890 ],
"role" : "Developer",
"fname" : "fname"
}, {
"id" : 124,
"name" : "Rahul Dravid",
"permanent" : false,
"address" : {
"street" : "Baner",
"city" : "Pune",
"zipcode" : 95014
},
"phoneNumbers" : [ 9988664422, 1234567890 ],
"role" : "Product owner",
"fname" : "fname"
} ]
Expected OUTPUT JSon:预期 OUTPUT JSon:
[ {
"id" : 123,
"firstname" : "Pankaj Kumar",
"permanent" : true,
"address" : {
"street" : "El Camino Real",
"city" : "San Jose",
"zipcode" : 95014
},
"phoneNumbers" : [ 9988664422, 1234567890 ],
"role" : "Developer",
"fname" : "fname"
}, {
"id" : 124,
"name" : "Rahul Dravid",
"permanent" : false,
"address" : {
"street" : "Baner",
"city" : "Pune",
"zipcode" : 95014
},
"phoneNumbers" : [ 9988664422, 1234567890 ],
"role" : "Product owner",
"fname" : "fname"
} ]
Use shift operation, to change the name to firstname使用 shift 操作,将 name 更改为 firstname
[
{
"operation": "shift",
"spec": {
"*": {
"id": "[&1].id",
"name": "[&1].firstname",
"permanent": "[&1].permanent",
"address": "[&1].address",
"phoneNumbers": "[&1].phoneNumbers",
"role": "[&1].role",
"#fname": "[&1].fname"
}
}
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.