我要编辑此json文件:
{
"shipping_orders": [{
}],
"timestamp": 100,
"shoporders": [{
"buyer_remark": null
}],
"payment_channel_info": {
"shipping_method": 28,
"grouping_info": {
"groups": [{
"display_info": {
"discount": 1
}
}]
}
}
}
我想将这些json对象添加到文件中
"headers": {}
"ext_ad_info_mappings": []
"enabled": true
我想要的输出是这样的:
{
"headers": {},
"shipping_orders": [{
}],
"timestamp": 100,
"shoporders": [{
"buyer_remark": null,
"ext_ad_info_mappings": []
}],
"payment_channel_info": {
"shipping_method": 28,
"grouping_info": {
"groups": [{
"display_info": {
"discount": 1,
"enabled": true
}
}]
}
}
}
我尝试了此命令,但结果仅显示true
https://jqplay.org/s/0aVbFzMttK
jq '.+{"headers": {}} and .shoporders[] + {"ext_ad_info_mappings": []} and .payment_channel_info.grouping_info.groups[].display_info + {"enabled": true}'
我应该如何编辑json文件,使其输出像我上面想要的那样?
答案 0 :(得分:0)
只需在树中要设置值的位置进行设置即可。
.headers = {}
| .shoporders[].ext_ad_info_mappings = []
| .payment_channel_info.grouping_info.groups[].display_info.enabled = true