The source for the Go SQL/JSON Path Playground, a stateless single-page web site for experimenting with the Go SQL/JSON Path package. Compiled via TinyGo into a ca. 930 K (360 K compressed) Wasm file and loaded directly into the page. All functionality implemented in JavaScript and Go, Go JSONPath Playground, Goldmark Playground and serde_json_path Sandbox.
On load, the form will be filled with sample JSON, a randomly-selected example query, and, in some cases, option adjustments for the query. Hit the "Run Query" button to see the values the path query selects from the JSON appear in the "Query Output" field.
To try your own, paste the JSON to query into the "JSON" field and input the jsonpath expression into the "Path" field, then hit the "Run Query" button to see the the values the path query selects from the JSON.
That's it.
Read on for details and additional features.
The two buttons in the top-right corner provide documentation and links.
-
Hit the button with the circled question mark in the top right corner to reveal a table summarizing the SQL/JSON Path syntax.
-
Hit the button with the circled i for information about the SQL/JSON Path playground.
Choose the mode in which to execute the jsonpath query. The options are:
- Query: Use Query to return an array of all the JSON items returned by the Path from the JSON.
- First: Like Query, but uses First to return only the first item, if any.
- Exists or Match: Use ExistsOrMatch to return
trueorfalsedepending on whether the query does or does not find results or match values, andnullif the result is unknown.
For the subtleties on the two behaviors of jsonpath expressions that use
Exists or Match, see Two Types of Queries.
Select options for execution and the display of results:
- WithSilent: Use WithSilent to suppress some errors, including missing object field or array element, unexpected JSON item type, and datetime and numeric errors.
- WithTZ: Use WithTZ to allow comparisons of datetime values that require timezone-aware conversions.
- LocalTZ: Use ContextWithTZ to parse times and timestamps in the context of your browser's local time zone instead of UTC.
Hit this button to reload the page with a URL that contains the contents of all the fields. Use for sharing.
Note that the Playground is stateless; no data is stored except in the Permalink URL itself (and whatever data collection GitHub injects; see its privacy statement for details).
Input the jsonpath expression to execute into this field. See the language docs or the PostgreSQL docs for details on the jsonpath language. Example:
$.a[*] ? (@ >= $min && @ <= $max)
Input the variables used in the Path as a JSON object. For example, the
Path example above references two variables, $min and $max. The object
to set their values might be:
{ "min": 2, "max": 4 }Input the JSON against which to execute the Path expression. May be any kind of JSON value, including objects, arrays, and scalar values. An example that the above Path expression successfully executes against:
{ "a": [1,2,3,4,5] }| Syntax Element | Description |
|---|---|
$ |
root node identifier |
@ |
current node identifier (valid only within filter selectors) |
."name" |
name selector: selects a named child of an object |
.name |
shorthand for ."name" |
.* |
wildcard selector: selects all children of a node |
.** |
recursive wildcard accessor: selects zero or more descendants of a node |
.**{3} |
recursive wildcard accessor: selects up to specified level of hierarchy |
.**{2 to 5} |
recursive wildcard accessor: selects from start to end level |
[<subscripts>] |
array selector with comma-delimited subscripts |
[3] |
index selector subscript: selects an indexed child of an array |
[3 to last] |
array slice subscript: select slice from start to end index (or last) |
[*] |
wildcard array selector: returns all array elements. |
$var_name |
a variable referring to a value in the Vars object |
strict |
raise error on a structural error |
lax |
suppress structural errors |
?(<expr>) |
filter selector: selects and transforms children |
.size() |
method selector |
Copyright (c) 2024-2025 David E. Wheeler. Distributed under the PostgreSQL License.
Based on Goldmark Playground the serde_json_path Sandbox, with icons from [Boxicons], all distributed under the MIT License.