我是JOLT转换的新手,有人能帮我把输入JSON转换成想要的输出吗?
- 输入JSON:**
[
{
"product_id": 1,
"product_description": "Product 1 details",
"billing_details": {
"product_id": 1,
"billing_description": "Product 1 billing Details"
},
"product_part_desc": {
"id": 1,
"part_description": "product 1 part description"
}
},
{
"product_id": 2,
"product_description": "Product 2 details",
"billing_details": {
"product_id": 1,
"billing_description": "Product 2 billing Details"
},
"product_part_desc": {
"id": 1,
"part_description": "product 2 part description"
}
}
]
- 试用规格:**
[
{
"operation": "shift",
"spec": {
"*": {
"product_id": "[&1].id",
"product_description": "[&1].description",
"billing_details": {
"billing_description": "[&2].bill_desc"
},
"*": "&"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"product_part_desc": "=toString(@(1,product_part_desc))"
}
}
}
]
- 预期产出:**
[
{
"id": 1,
"product_description": "Product 1 details",
"billing_description": "Product 1 billing Details",
"product_part_desc": "{id=1, part_description=product 1 part description}"
},
{
"product_id": 2,
"product_description": "Product 2 details",
"billing_description": "Product 2 billing Details",
"product_part_desc": "{id=1, part_description=product 2 part description}"
}
]
但上述规格给出了以下输出
2条答案
按热度按时间ggazkfy81#
您可以使用:
product_part_desc
**属性@billing_details.billing_description
标识符以及shift转换规范,以获取billing_description
**属性结果是:
bvn4nwqk2#
可以使用此等级库:
您可以在上面的代码中根据需要更改密钥。