英文:
jq Invalid numeric literal at EOF updating json value to 0.0.x
问题
我试图按照以下方式更新我的 JSON 文件:
jq .attributes.DeployVersion.default=0.0.1 block.json > t.tmp && mv t.tmp block.json
这会引发错误:
jq: error: Invalid numeric literal at EOF at line 1, column 5 (while parsing '0.0.0') at <top-level>, line 1:
.attributes.DeployVersion.default=0.0.1
而这个命令:
jq .attributes.DeployVersion.default=0.1 block.json > t.tmp && mv t.tmp block.json
却可以正常工作(唯一的区别是我使用了 0.1 而不是 0.0.1)。尝试使用引号没有起作用。
英文:
i am trying to update my json file as following
jq .attributes.DeployVersion.default=0.0.1 block.json > t.tmp && mv t.tmp block.json
which throws an error
jq: error: Invalid numeric literal at EOF at line 1, column 5 (while parsing '0.0.0') at <top-level>, line 1:
.attributes.DeployVersion.default=0.0.1
while this:
jq .attributes.DeployVersion.default=0.1 block.json > t.tmp && mv t.tmp block.json
works perfectly (the only difference is instead of 0.0.1 I use 0.1)
tried quotes, didnt work.
答案1
得分: 2
Quotes around both the version string and the whole expression:
jq -r '.attributes.DeployVersion.default="0.0.2"'
Or escape the quotes around the version string:
jq -r .attributes.deployVersion.default=\"0.0.2\"
You could also use tostring
in a pipe, but it would be unnecessary.
英文:
Quotes around both the version string and the whole expression:
jq -r '.attributes.DeployVersion.default="0.0.2"'
Or escape the quotes around the version string:
jq -r .attributes.deployVersion.default=\"0.0.2\"
You could also use tostring
in a pipe, but it would be unnecessary.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论