SyntaxDock guide

JSONPath Syntax Guide

Learn the core JSONPath operators used to select values from nested JSON documents.

Start with a small document

The JSONPath Tester has separate JSON and expression editors. Paste the document below into JSON, enter a query, and select Run JSONPath. Values and normalized paths are calculated locally; the document is never uploaded.

{"items":[{"name":"dock","price":8},{"name":"lamp","price":15}],"owner":{"name":"Alex"}}

Root and child selectors

$ selects the complete document. $.owner.name selects "Alex"; $['owner']['name'] expresses the same lookup. Quoted bracket notation also addresses keys containing spaces or punctuation. A missing key gives no match.

Wildcards, descendants and indexes

$.items[*].name selects both item names. $..name searches descendants and also finds the owner name. Use $.items[0] for the first item and $.items[-1] for the last. An out-of-range index produces no match.

Array slices

$.items[0:2] selects indexes zero and one; the end is exclusive. $.items[::2] selects every second item. A negative step, as in $.items[::-1], traverses in reverse. Slices operate on arrays, not strings.

Filters and standard functions

$.items[?@.price < 10].name selects "dock". Inside a filter, @ denotes the candidate being tested. Combine conditions with &&, ||, and !.

RFC 9535 defines length() for string, array or object size; count() for node counts; value() for a single node's value; and regular-expression functions match() (whole string) and search() (substring). For example, $.items[?length(@.name) == 4] selects both items. Functions have typed arguments; an invalid expression is reported rather than evaluated as JavaScript.

Read normalized paths and empty results

For the first name, SyntaxDock displays $['items'][0]['name']. This identifies the location independently of the query that found it. Zero matches is a successful query result, not a syntax error; check key spelling and filter conditions. A selected JSON null is a value and differs from a missing match.

Dialect and display limits

SyntaxDock implements RFC 9535, not legacy JavaScript-expression dialects. Script selectors, arbitrary function calls and executable expressions are unsupported. JSON comments and trailing commas are invalid. The workspace accepts up to 2 MiB of JSON and an 8 KiB expression, and displays up to 1,000 matches with total and displayed counts. Use the tool's examples to explore supported selectors before adapting a query from another library.

For the formal grammar, see the RFC 9535 specification.