jq - Cannot index string with string

In my case jq '[.[] | group_by(.foo)]' gave the error but jq '[.[]] | group_by(.foo)' worked


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.

Tags:

Shell

Jq