我遇到了一个问题,使用jolt转换转换一个非常复杂的嵌套JSON.输入和输出细节如下所示.
我试图创建一个震动规格,但没有得到它.有人可以请帮助我.详情如下:
输入JSON
{
"key": [
{
"date": "27/09/2023"
}
],
"value": [
{
"values": [
{
"location": "3005",
"total_capacity": 24,
"capacity_flag": "",
"orders": [
{
"order_type": "INIT",
"consumed_capacity": 0
},
{
"order_type": "PUSH",
"consumed_capacity": 0
}
]
},
{
"location": "3007",
"total_capacity": 72,
"capacity_flag": "",
"orders": [
{
"order_type": "INIT",
"consumed_capacity": 0
},
{
"order_type": "PUSH",
"consumed_capacity": 0
},
{
"order_type": "RPLN",
"consumed_capacity": 0
}
]
}
]
}
]
}
期望输出
[
{
"date": "27/09/2023",
"location": "3005",
"total_capacity": 24,
"capacity_flag": "",
"order_type": "INIT",
"consumed_capacity": 0
},
{
"date": "27/09/2023",
"location": "3005",
"total_capacity": 24,
"capacity_flag": "",
"order_type": "PUSH",
"consumed_capacity": 0
},
{
"date": "27/09/2023",
"location": "3007",
"total_capacity": 72,
"capacity_flag": "",
"order_type": "INIT",
"consumed_capacity": 0
},
{
"date": "27/09/2023",
"location": "3007",
"total_capacity": 72,
"capacity_flag": "",
"order_type": "PUSH",
"consumed_capacity": 0
},
{
"date": "27/09/2023",
"location": "3007",
"total_capacity": 72,
"capacity_flag": "",
"order_type": "RPLN",
"consumed_capacity": 0
}
]
我试过的Jolt Spec,但日期不正确
[
{
"operation": "shift",
"spec": {
"value": {
"*": {
"values": {
"*": {
"orders": {
"*": {
"order_type": "&3.&1.order_type",
"consumed_capacity": "&3.&1.consumed_capacity",
"@2,location": "&3.&1.location",
"@2,total_capacity": "&3.&1.total_capacity",
"@2,capacity_flag": "&3.&1.capacity_flag"
}
}
}
}
}
}
}
},
{ // get rid of the object keys generated within the previous spec
"operation": "shift",
"spec": {
"*": {
"*": ""
}
}
}
]
需要帮助写一个震动规范,使我们得到一个扁平数组