How do I use jq to convert number to string?

后端 未结 4 1103
孤街浪徒
孤街浪徒 2020-12-29 01:56

Given the following jq command and Json:

jq \'.[]|[.string,.number]|join(\": \")\' <<< \'
[
  {
    \"number\": 3,
    \"string\": \"threee\"
  },
          


        
4条回答
  •  攒了一身酷
    2020-12-29 02:37

    use 'map_values' opearator to modify objects

    Example

    {"foo": {"bar": 3}}

    .foo.bar = .foo.bar|map_values(tostring)

    Output

    { "foo": { "bar": "3" } }

提交回复
热议问题