0

we have the follwing json file

 more t.json
{
  "href" : "htr",
  "items" : [
    {
      "href" : "lpo",
      "tag" : "version1533203561827110",
      "type" : "kafka-log4j",
      "version" : 6,
      "Config" : {
        "cluster_name" : "hdp",
        "stack_id" : "HDP-2.6"
      },
      "properties" : {
        "content" : "Licensed to the Apache Software Foundation",
        "controller_log_maxbackupindex" : "20",
        "controller_log_maxfilesize" : "256",
        "ey=log4j.rootLogger" : "DEBUG",
        "ey=properties.content" : "DEBUG",
        "kafka_log_maxbackupindex" : "20",
        "kafka_log_maxfilesize" : "256"
      }
    }
  ]
}

we want to print only the value of content

jq '.items[].properties | to_entries[] |  " \(.value)"' t.json
" Licensed to the Apache Software Foundation"
" 20"
" 256"
" DEBUG"
" DEBUG"
" 20"
" 256"

but its print all the other values

where I am wrong , and what should I fix ?

expected output

" Licensed to the Apache Software Foundation"
6

Try this,

jq '.items[].properties.content' t.json

Add -r if you want to get rid of the double quotes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.