Categorygithub.com/theory/jsonpath
modulepackage
0.4.0
Repository: https://github.com/theory/jsonpath.git
Documentation: pkg.go.dev

# README

RFC 9535 JSONPath in Go

⚖️ MIT 📚 Docs 🗃️ Report Card 🛠️ Build Status 📊 Coverage

The jsonpath package provides RFC 9535 JSONPath functionality in Go.

Learn More

JSONPath Expressions

A brief overview of RFC 9535 JSONPath syntax:

Syntax ElementDescription
$root node identifier
@current node identifier (valid only within filter selectors)
[<selectors>]child segment: selects zero or more children of a node
.nameshorthand for ['name']
.*shorthand for [*]
..[<selectors>]descendant segment: selects zero or more descendants of a node
..nameshorthand for ..['name']
..*shorthand for ..[*]
'name'name selector: selects a named child of an object
*wildcard selector: selects all children of a node
3index selector: selects an indexed child of an array (from 0)
0:100:5array 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

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

# Packages

Package parser parses RFC 9535 JSONPath queries into parse trees.
Package registry provides a RFC 9535 JSONPath function registry.
Package spec provides object definitions and execution for RFC 9535 JSONPath query expressions.

# Functions

MustParse parses path into a Path.
New creates and returns a new Path consisting of q.
NewParser creates a new Parser configured by opt.
Parse parses path, a JSONPath query string, into a Path.
WithRegistry configures a Parser with a function Registry, which may contain function extensions.

# Variables

ErrPathParse errors are returned for path parse errors.

# Structs

Parser parses JSONPath strings into [*Path]s.
Path represents a [RFC 9535] JSONPath query.

# Type aliases

LocatedNodeList is a list of nodes selected by a JSONPath query, along with their locations.
NodeList is a list of nodes selected by a JSONPath query.
Option defines a parser option.