Skip to content

Methods and piping

The language relies mainly on methods to do transformation work, both those built into the library and external methods you write in C# and register.

All method calls begin with # and are case-sensitive. Parentheses surround the arguments, which are comma-separated.

{
"value": "#valueOf($.some.json.path)"
}

The argument here is a JSON Path query. It selects the value at that path in the source document. Most library methods accept either a path, as above, or a value taken from the source document.

{
"valueExists": "#exists($.some.json.path)",
"otherValueExists": "#exists(#valueOf($.some.other.json.path))"
}

The -> operator passes the result of one expression as the first argument of the next method. That argument is then left out of the second call.

{
"valueExists": "#valueOf($.some.json.path)->#exists()"
}

If you know C# extension methods, this is the same idea. Any method, including your own external methods, can be called standalone or piped. Piping lets a chain read left to right:

{
"names": "#valueOf($.people)->#where(@p: @p.active)->#select(@p: @p.name)->#joinWith(', ')"
}

You can also pipe directly from a variable:

{
"@someVariable": "#valueOf($.some.arrayPath)",
"result": "@someVariable->#select(@y: @y->#length())"
}