The content is
{
"properties" : {
"CloudSanityPassed" : [ "true" ],
"GITCOMMIT" : [ "test1" ],
"buildNumber" : [ "54" ],
"jobName" : [ "InveergDB-UI" ]
},
"uri" : "http://ergctory:8081/aergergory/api/storage/test-reergerglease-reergpo/cergom/cloergud/waf/ergregBUI/1ergerggregSHOT/ergregerg-34.zip"
}
I use this command
.[] | ."CloudSanityPassed" | .[]
And I get this message
jq: error (at <stdin>:8): Cannot index string with string "CloudSanityPassed"
"true"
exit status 5
I get, what I want ("true" value), but there is a error in output. Could you explain me, how to avoid it and why does it happen?
According to the jq manual, .[]
gets the values of the object when applied to object.
So you get two objects, one for value of "properties"
and another for value of "uri"
:
{
"CloudSanityPassed": [
"true"
],
"GITCOMMIT": [
"test1"
],
"buildNumber": [
"54"
],
"jobName": [
"InveergDB-UI"
]
}
"http://ergctory:8081/aergergory/api/storage/test-reergerglease-reergpo/cergom/cloergud/waf/ergregBUI/1ergerggregSHOT/ergregerg-34.zip"
jq
tries to apply ."CloudSanityPassed"
operator to each object.
Since former object is dictionary (aka hash), you can apply ."CloudSanityPassed"
and get the value ["true"]
, however, latter is an simple string which you cannot apply ."CloudSanityPassed"
, so jq
outputs error here.
Maybe the command you want is just .properties.CloudSanityPassed
.
In my case jq '[.[] | group_by(.foo)]'
gave the error but
jq '[.[]] | group_by(.foo)'
worked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With