且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jq将数字转换为字符串?

更新时间:2023-02-03 07:58:07

jq命令具有 tostring 功能.我花了一段时间才学会通过反复试验来使用它.使用方法如下:

The jq command has the tostring function. It took me a while to learn to use it by trial and error. Here is how to use it:

jq -r '.[] | [ .string, .number|tostring ] | join(": ")' <<< '
[{ "number": 9, "string": "nine"},
 { "number": 4, "string": "four"}]
'
nine: 9
four: 4