gpt4 book ai didi

jq:更改多个值

转载 作者:行者123 更新时间:2023-12-04 04:58:45 25 4
gpt4 key购买 nike

我正在尝试使用此行更改多个 json 值

 jq '.two="newval", .three="newval"' my.json 

这是输入
{
"one": {
"val": 1
},
"two": "val",
"three": "val",
"four": "val"
}

但输出是 2 个 jsons:
{
"one": {
"val": 1
},
"two": "newval",
"three": "val",
"four": "val"
}
{
"one": {
"val": 1
},
"two": "val",
"three": "newval",
"four": "val"
}

如何在一项中更改多个值和输出?

最佳答案

只需将逗号更改为竖线字符即可:

.two="newval" | .three="newval"

","用于连接流: A,B将发出 A,然后是 B。

关于jq:更改多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47355901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com