我遇到了一个问题,使用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
}
]
型
我试过的震动规格,但日期不正确
[
{
"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": {
"*": {
"*": ""
}
}
}
]
型
需要帮助写一个震动规范,使我们得到一个扁平阵列
2条答案
按热度按时间tyg4sfes1#
你只需要再次向上走,并拿起日期之前,包括它到您的输出。
这里有一个想法,你可以如何实现这一点(注意,我假设你将永远有一个日期)
字符串
avkwfej42#
一个更有活力和体面的选择可能是
字符串
网站https://jolt-demo.appspot.com/上的 * 演示 * 是:
的数据