Skip to content

Instantly share code, notes, and snippets.

@nichtich
Last active March 3, 2022 10:29
Show Gist options
  • Save nichtich/976d7ac8a5fcc2e896cc86795f2ee416 to your computer and use it in GitHub Desktop.
Save nichtich/976d7ac8a5fcc2e896cc86795f2ee416 to your computer and use it in GitHub Desktop.
JSON query languages

JSON query languages

  • JSONPath is was created 2007, inspired by XPath. A formal standard is being created at https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base
  • SQL/JSON path was created inspired by JSONPath and other query languages.
  • jq is a programming language with strong support of JSON transformation
  • JSON Pointer only references a single element

Most important conflicting difference between JSONPath and SQL/JSON path is $.["name"] vs $."name" and $[? filter ] vs $?(filter).

Other JSON query languages

  • JAQL
  • JMESPath
  • JSONata
  • JSONiq
  • JSONPath

Minimal subset of JSONPath (JSON Basic Path)

  • No filter expression
  • No list selector
  • No array slice
  • No functions
  • No Descendant Selector
json-basic-path = root-selector *(S (dot-selector        /
                               dot-wild-selector   /
                               index-selector      /
                               index-wild-selector ))
$
$.*
$.name
$."name" not allowed in JSONPath !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment