How to get key names from JSON using jq

前端 未结 7 1027
[愿得一人]
[愿得一人] 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:28

    You need to use jq 'keys[]'. For example:

    echo '{"example1" : 1, "example2" : 2, "example3" : 3}' | jq 'keys[]'
    

    Will output a line separated list:

    "example1"
    "example2"
    "example3"
    

提交回复
热议问题