Using jq to fetch key value from json output

后端 未结 3 1056
暖寄归人
暖寄归人 2021-02-12 08:29

I have a file that looks as below:

{
  \"repositories\": [
   {
    \"id\": \"156c48fc-f208-43e8-a631-4d12deb89fa4\",
    \"namespace\": \"rhel12\",
    \"namesp         


        
3条回答
  •  醉梦人生
    2021-02-12 09:00

    You want to look at the repositories array instead of treating the input as an array:

    $ jq -r '.repositories[].name' file
    rhel6.6
    rhel7
    

提交回复
热议问题