Jolt JSON 空问题
Jolt JSON null issue
我对 JSON\
的 Jolt 转换有疑问
输入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"
}
]
},
{
"poi_id": "6218e53465793fa20ea11525",
"patientorderlogs": [
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
},
{
"poi_id": "6218e53465793fa20ea11525",
"patientorderlogs": [
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
}
]
}
JOLT规格:
[
{
"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": {
"*": {
"*": ""
}
}
}
]
输出:
[ {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea1152a",
"pol_id" : "6218e53465793fa20ea1152e",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea1152a",
"pol_id" : "6218e53465793fa20ea1152c",
"useruid" : "61ee4995f16eebb6b7e1c643",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
} ]
我期望 JSONS 的数组没有空值
为什么我得到空数组
我可以对震动规范做任何更改吗?
..................................................... ..................................................... ..................................................... .....................................
您可以通过添加 @(3,poi_id)
作为值(作为右侧,将所需级别从 2 提高到 3)为了区分对象多如
[
{
"operation": "shift",
"spec": {
"patientorderitems": {
"*": {
"patientorderlogs": {
"*": {
"@(4,_id)": "@(3,poi_id)[&3].&1._id",
"@(2,poi_id)": "@(3,poi_id)[&3].&1.poi_id",
"*": "@(3,poi_id)[&3].&1.&"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": ""
}
}
}
}
]
在这种情况下,您还将摆脱 nulls 作为添加一个额外的级别("*": {..}
) 最后一个规格。
网站上的演示 http://jolt-demo.appspot.com/ 是
我对 JSON\
的 Jolt 转换有疑问输入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"
}
]
},
{
"poi_id": "6218e53465793fa20ea11525",
"patientorderlogs": [
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
},
{
"poi_id": "6218e53465793fa20ea11525",
"patientorderlogs": [
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
},
{
"pol_id": "6218e53465793fa20ea11529",
"useruid": "61ee4995f16eebb6b7e1c644",
"modifiedat": "2022-02-25T17:18:28Z"
}
]
}
]
}
JOLT规格:
[
{
"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": {
"*": {
"*": ""
}
}
}
]
输出:
[ {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea1152a",
"pol_id" : "6218e53465793fa20ea1152e",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea1152a",
"pol_id" : "6218e53465793fa20ea1152c",
"useruid" : "61ee4995f16eebb6b7e1c643",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
}, null, null, null, {
"_id" : "6218e53465793fa20ea11524",
"poi_id" : "6218e53465793fa20ea11525",
"pol_id" : "6218e53465793fa20ea11529",
"useruid" : "61ee4995f16eebb6b7e1c644",
"modifiedat" : "2022-02-25T17:18:28Z"
} ]
我期望 JSONS 的数组没有空值
为什么我得到空数组
我可以对震动规范做任何更改吗? ..................................................... ..................................................... ..................................................... .....................................
您可以通过添加 @(3,poi_id)
作为值(作为右侧,将所需级别从 2 提高到 3)为了区分对象多如
[
{
"operation": "shift",
"spec": {
"patientorderitems": {
"*": {
"patientorderlogs": {
"*": {
"@(4,_id)": "@(3,poi_id)[&3].&1._id",
"@(2,poi_id)": "@(3,poi_id)[&3].&1.poi_id",
"*": "@(3,poi_id)[&3].&1.&"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": ""
}
}
}
}
]
在这种情况下,您还将摆脱 nulls 作为添加一个额外的级别("*": {..}
) 最后一个规格。
网站上的演示 http://jolt-demo.appspot.com/ 是