How to get key names from JSON using jq

前端 未结 7 996
[愿得一人]
[愿得一人] 2020-11-29 22:15

curl http://testhost.test.com:8080/application/app/version | jq \'.version\' | jq \'.[]\'

The above command outputs only the values as below:

         


        
相关标签:
7条回答
  • 2020-11-29 22:36

    To get the keys on a deeper node in an JSON:

    echo '{"data": "1", "user": { "name": 2, "phone": 3 } }' | jq '.user | keys[]'
    "name"
    "phone"
    
    0 讨论(0)
提交回复
热议问题