[英]Jolt JSON transformation
I want to transform this JSON:我想改造这个JSON:
{
"_id": "6218e53465793fa20ea11524",
"patientorderitems": [
{
"poi_id": "6218e53465793fa20ea1152a",
"patientorderlogs": [
{
"pol_id": "6218e53465793fa20ea1152e",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea1152c",
"useruid": "61ee4995f16eebb6b7e1c643",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
},
{
"poi_id": "6218e53465793fa20ea11525",
"patientorderlogs": [
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
}
]
}
To this JSON:给这个 JSON:
[
{
"_id": "6218e53465793fa20ea11524",
"poi_id": "6218e53465793fa20ea1152a",
"pol_id": "6218e53465793fa20ea1152e",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"_id": "6218e53465793fa20ea11524",
"poi_id": "6218e53465793fa20ea1152a",
"pol_id": "6218e53465793fa20ea1152c",
"useruid": "61ee4995f16eebb6b7e1c643",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"_id": "6218e53465793fa20ea11524",
"poi_id": "6218e53465793fa20ea11525",
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
I am currently using this specification and it not work for me:我目前正在使用此规范,但它对我不起作用:
[
{
"operation": "shift",
"spec": {
"patientorderitems": {
"*": {
"patientorderlogs": {
"*": {
"@(4,_id)": "[&3]._id",
"@(2,poi_id)": "[&3].poi_id",
"pol_id": "[&3].pol_id",
"useruid": "[&3].useruid",
"modifiedat": "[&3].modifiedat"
}
}
}
}
}
}
]
Can some one give a specification for this please and is there any clear documentation for jolt JSON有人可以为此提供一个规范吗,是否有任何关于 jolt JSON 的明确文档
.................................................................... ............................................................ ..................................................... ................................................... .....................................
One more level of node is needed.需要多一层节点。 For this aim, you can prepend all values of the innermost attributes by &1.
为此,您可以在最内层属性的所有值前加上&1.
. .
Then an extra shift transformation is added to remove unwanted key names and square brackets wrapping the objects.然后添加一个额外的移位转换以删除不需要的键名和包裹对象的方括号。
So, you can use the following specs:因此,您可以使用以下规格:
[
{
"operation": "shift",
"spec": {
"patientorderitems": {
"*": {
"patientorderlogs": {
"*": {
"@(4,_id)": "&1.[&3]._id",
"@(2,poi_id)": "&1.[&3].poi_id",
"*": "&1.[&3].&" // combine all innermost attributes by "*" wildcard
}
}
}
}
}
},
{
//get rid of indexes and wrapper brackets
"operation": "shift",
"spec": {
"*": {
"*": ""
}
}
}
]
the demo on the site http://jolt-demo.appspot.com/站点http://jolt-demo.appspot.com/上的演示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.