https://github.com/theory/jsonpath
RFC 9535 JSONPath in Go
https://github.com/theory/jsonpath
json json-path jsonpath rfc9535
Last synced: 5 months ago
JSON representation
RFC 9535 JSONPath in Go
- Host: GitHub
- URL: https://github.com/theory/jsonpath
- Owner: theory
- License: mit
- Created: 2024-09-06T15:37:42.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-15T17:06:18.000Z (6 months ago)
- Last Synced: 2025-01-30T17:27:04.712Z (5 months ago)
- Topics: json, json-path, jsonpath, rfc9535
- Language: Go
- Homepage: https://theory.github.io/jsonpath
- Size: 202 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
RFC 9535 JSONPath in Go
=======================[![⚖️ MIT]][mit] [![📚 Docs]][docs] [![🗃️ Report Card]][card] [![🛠️ Build Status]][ci] [![📊 Coverage]][cov]
The jsonpath package provides [RFC 9535 JSONPath] functionality in Go.
## Learn More
* 📦 See the [package documentation][docs] 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].## JSONPath Expressions
A brief overview of [RFC 9535 JSONPath] syntax:
| Syntax Element | Description |
| ------------------ | ----------------------------------------------------------------------- |
| `$` | root node identifier |
| `@` | current node identifier (valid only within filter selectors) |
| `[]` | child segment: selects zero or more children of a node |
| `.name` | shorthand for `['name']` |
| `.*` | shorthand for `[*]` |
| `..[]` | 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 |
| `?` | filter selector: selects particular children using a logical expression |
| `length(@.foo)` | function extension: invokes a function in a filter expression |## Package Stability
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
Copyright © 2024-2025 David E. Wheeler
[⚖️ MIT]: https://img.shields.io/badge/License-MIT-blue.svg "⚖️ MIT License"
[mit]: https://opensource.org/license/MIT "⚖️ MIT License"
[📚 Docs]: https://godoc.org/github.com/theory/jsonpath?status.svg "📚 Documentation"
[docs]: https://pkg.go.dev/github.com/theory/jsonpath "📄 Documentation"
[🗃️ Report Card]: https://goreportcard.com/badge/github.com/theory/jsonpath
"🗃️ Report Card"
[card]: https://goreportcard.com/report/github.com/theory/jsonpath
"🗃️ Report Card"
[🛠️ Build Status]: https://github.com/theory/jsonpath/actions/workflows/ci.yml/badge.svg
"🛠️ Build Status"
[ci]: https://github.com/theory/jsonpath/actions/workflows/ci.yml
"🛠️ Build Status"
[📊 Coverage]: https://codecov.io/gh/theory/jsonpath/graph/badge.svg?token=UB1UJ95NIK
"📊 Code Coverage"
[cov]: https://codecov.io/gh/theory/jsonpath "📊 Code Coverage"
[RFC 9535 JSONPath]: https://www.rfc-editor.org/rfc/rfc9535.html
"RFC 9535 JSONPath: Query Expressions for JSON"
[Playground]: https://theory.github.io/jsonpath/ "Go JSONPath Playground"