The jsonpath package provides RFC 9535 JSONPath functionality in Go.
- 📦 See the package documentation for usage and examples.
- 📚 See the RFC 9535 JSONPath standard for details on the JSONPath query syntax and examples of its usage.
- 🛝 Try it out in the Playground.
A brief overview of RFC [9535 JSONPath] syntax:
Syntax Element | Description** |
---|---|
$ |
root node identifier |
@ |
current node identifier (valid only within filter selectors) |
[<selectors>] |
child segment: selects zero or more children of a node |
.name |
shorthand for ['name'] |
.* |
shorthand for [*] |
..[<selectors>] |
descendant segment: selects zero or more descendants of a node |
..name |
shorthand for ..['name'] |
..* |
shorthand for ..[*] |
'name' |
name selector: selects a named child of an object |
* |
wildcard selector: selects all children of a node |
3 |
index selector: selects an indexed child of an array (from 0) |
0:100:5 |
array slice selector: start:end:step for arrays |
?<logical-expr> |
filter selector: selects particular children using a logical expression |
length(@.foo) |
function extension: invokes a function in a filter expression |
The root jsonpath
package is stable and ready for use. These are the main
interfaces to the package.
The registry
package is also stable, but exposes data types from the spec
package that are still in flux. Argument data types may still change.
The parser
package interface is also stable, but in general should not be
used directly.
The spec
package remains under active development, mainly refactoring,
reorganizing, renaming, and documenting. Its interface therefore is not stable
and should not be used for production purposes.
Copyright © 2024 David E. Wheeler