Skip to content

Instantly share code, notes, and snippets.

@tleyden
Last active January 24, 2017 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tleyden/6c771dec582813844c82c99952639e6d to your computer and use it in GitHub Desktop.
Save tleyden/6c771dec582813844c82c99952639e6d to your computer and use it in GitHub Desktop.

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