Convert string to json in jq

后端 未结 2 1155
臣服心动
臣服心动 2021-02-03 17:29

Background

I have a json file that contains a string of json within an object:

{
    \"requestType\": \"POST\",
    \"response\": {
        \"size\": 7         


        
相关标签:
2条回答
  • 2021-02-03 18:05

    Use fromjson.

    It parses a string to its appropriate json value. tojson (and @json) goes the other way around and takes a json value and converts it to a string.

    So you could do this:

    .response.text | fromjson.title
    
    0 讨论(0)
  • 2021-02-03 18:09

    You can also do this:

    jq -r '.response.text' | jq '.recordID'
    
    0 讨论(0)
提交回复
热议问题