Skip to main content

JSONPath

The mapping engine is jsonpath-plus running in an embedded JavaScript runtime. This page lists what that build actually supports. Every result below was produced by running the expression through the engine the flow uses. Unless a section says otherwise, the examples run against this data:
An expression must start with $. — those two characters are what marks a string as a path. $['fetch_customer']['name'], $[0] and a bare $ all start with $ but not $., so they are copied through as literal text and never resolved. Write $.fetch_customer['name'] instead: bracket notation is fine anywhere after the opening $..

Selectors

Bracket notation

Needed whenever a key is not a plain identifier — spaces, dots, hyphens, or a numeric key.

Slices

A bare negative index does not work. $.fetch_order.items[-1] returns [], not the last item. Only the slice form counts from the end, so the last element is [-1:] — and because a one-element slice is a single hit, it returns the value itself rather than a one-item array.The index-free alternative is a script index: $.fetch_order.items[(@.length-1)].product returns "Doohickey".

Recursive descent

.. searches every level below the point it appears.

Parent and property operators


Filters

A filter is [?( … )]. The body is a JavaScript expression evaluated once per candidate, with @ bound to the candidate. Ordinary JavaScript methods on the candidate’s own values work: A filter may contain another filter, as long as the inner one is the whole test:
It cannot be followed by anything. $.users[?(@.orders[?(@.total>1000)].length>5)] fails to parse with Unexpected "?" at character 12, and combining it with && returns no matches rather than an error. Count in an Eval step instead.

Context variables

Use @root, not $, to reach outside the candidate. $ is not defined inside a filter body — [?(@.id===$.trigger.id)] fails the step with $ is not defined.

What does not work

Each of these fails the step outright. The error text below is what the engine returns.

| anywhere in the path

| is the concatenation delimiter and is consumed before the string ever reaches JSONPath, so a path containing one is split into fragments and each fragment is parsed separately.
There is no way to express OR in a filter. Restructure as two mappings, or move the logic into an Eval step. The same restriction means a literal | cannot appear in a mapped string at all.

Unquoted string literals

A bare word in a comparison is parsed as a variable name.
Quote it: [?(@.role==='admin')].

A single =

Use === or ==.

Type selectors

@string(), @number(), @integer(), @boolean(), @array(), @object(), @null(), @scalar() and @undefined() all fail to parse in this build.
typeof @.v === 'number' and typeof @ === 'string' are the working substitutes. For array and object tests, use an Eval stepArray.isArray is not in scope inside a filter.

Aggregation functions

@min(), @max(), @avg(), @sum() and .max() do not exist.
Aggregate in an Eval step.

[*] inside a filter body

Use @.expertise.indexOf('api')>-1.

A bare @ on its own

@ must be followed by a property, or wrapped in typeof.

Host globals

String, Number, Array, Object and friends are not in scope inside a filter body.
Methods on the candidate’s own values are fine — it is only the global constructors that are missing.
A filter that reads a property missing from any candidate fails the whole step, rather than skipping that candidate. If one row in a list has no address, then [?(@.address.city==='Boston')] errors with Cannot read properties of undefined (reading 'city') and the run ends. Guard it: [?(@.address && @.address.city==='Boston')].

Errors you will see

There is no separate validation pass. An unresolvable mapping fails the step with failed to resolve jPath and the message from the engine. The messages come from JSONPath and its expression parser, so they read like JavaScript errors: A path that simply matches nothing is not an error — see the two failure modes.

Next steps

Concatenation

Building strings with |

Examples

Worked mappings, run end to end

Eval Step

Where logic JSONPath cannot express belongs

Overview

Data sources, path shapes, failure modes