Create a gist now

Instantly share code, notes, and snippets.

@tleyden /jq.md
Last active Jan 24, 2017

Embed
What would you like to do?

JSON Input

{
  "rows": [
    {
      "key": "0-writer-user-0-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e",
      "id": "0-writer-user-0-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e",
      "value": {
        "rev": "1-eb773b445a2f94651e418fbaa670c8ef",
        "channels": [
          "1-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e"
        ]
      }
    },
    {
      "key": "0-writer-user-0-afc58c69-3dd9-494b-9da3-1d5854782770",
      "id": "0-writer-user-0-afc58c69-3dd9-494b-9da3-1d5854782770",
      "value": {
        "rev": "1-53d07cb11eef243d8069fc760b0073d5",
        "channels": [
          "9-afc58c69-3dd9-494b-9da3-1d5854782770"
        ]
      }
    }
  ]
}

JQ command

$ cat /tmp/all_docs | jq -c '.rows[] | .value.channels[]'

Output

"0-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e"
"2-afc58c69-3dd9-494b-9da3-1d5854782770"
"4-f2a2f5bf-72cd-4142-9dc3-eb8a133b4266"
"6-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e"
"9-afc58c69-3dd9-494b-9da3-1d5854782770"
"9-f2a2f5bf-72cd-4142-9dc3-eb8a133b4266"
"4-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e"
"1-afc58c69-3dd9-494b-9da3-1d5854782770"
"5-f2a2f5bf-72cd-4142-9dc3-eb8a133b4266"
"5-a2dd54dc-3301-4a9e-af23-7eb0fb293b7e"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment