Skip to content
@deckyard/jsonpath

jsonpath cheatsheet

Every export of @deckyard/jsonpath. Guides are listed in the introduction.

jennifer
import "@deckyard/jsonpath/" as jsonpath;

Constants

ConstantValueMeaning
ERROR_KIND"jsonpath"the kind of every error the deck throws
MAX_NESTING64how deep parentheses, filters and calls may nest
MAX_NODES1000000the default Path.maxNodes
MAX_INDEX9007199254740991the largest index or slice bound, 2^53 - 1

Types

Path

A parsed query, from compile.

FieldMeaning
source as stringthe query as written
nodes as list of Nodethe parsed form
root as intthe query node's index
maxNodes as intthe most nodes one segment may produce; lower it for untrusted queries

Match

FieldMeaning
value as json.Valuethe selected value
pointer as stringits JSON Pointer
path as stringits normalized path

Node

One node of the parsed form; read it through the deck.

FieldMeaning
kind as intwhat the node is
text as stringa name, a function name or an operator
num as intan index, a flag or a type
start as inta slice's start
stop as inta slice's end
step as inta slice's step
hasStart as boolthe slice gives a start
hasStop as boolthe slice gives an end
lit as json.Valuea literal's value
kids as list of intthe child nodes

Functions

FunctionReturnsDoes
jsonpath.query(doc, path)list of json.Valuethe values a query selects
jsonpath.paths(doc, path)list of stringtheir JSON Pointers
jsonpath.normalizedPaths(doc, path)list of stringtheir normalized paths
jsonpath.compile(path)Pathparse a query once
jsonpath.find(doc, path)list of Matchrun a compiled query: value, pointer and normalized path of each node
jsonpath.isValid(path)boolwhether a string is a valid query