Skip to content

Instantly share code, notes, and snippets.

@deptno
Last active April 2, 2018 11:46
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 deptno/f697f39947f8902a35760f5b9c42acef to your computer and use it in GitHub Desktop.
Save deptno/f697f39947f8902a35760f5b9c42acef to your computer and use it in GitHub Desktop.
cheatsheet: jq vs javascript comparison

collection

find

{
  "data": {
    "people": [
      {
        "name": "deptno"
      },
      {
        "name": "Bonggyun Lee"
      }
    ]
  }
}

jq

jq '.data.people[] | select(.name | contains("dept"))' jq '.data.people[] | select(.name == "deptno")'

javascript

json.data.people.find(person => person.name === 'deptno')

result

{
  "name": "deptno"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment