jpl

JPL - JSON Processing Language - Specification

How to use this document

Regexp expressions are used in this document to describe specific formats. \d is used for decimal digits and is equivalent to [0-9].

When describing definitions, other definitions are referenced like {definition-name} and expressions which must result in a specific type are referred like {expression -> type}. This form is not part of the language but is only used for this documentation.

Basic concepts

A program is built by one or more expressions, separated by the pipe operator.

Each expression takes multiple inputs, processes them one by one, and can also generate any number of outputs afterwards. All outputs are concatenated and passed into the next expression. Expressions that reference variables also run for each single value of each variable. Array constructors can be used to combine multiple outputs into a single array.

JPL expects all expressions (including (native) function calls) to be idempotent, meaning that an expression should always produce the same output when run in the same environment (input, variables). This allows subsequent calls to be cached which has large impact on the overall performance.

Indices are zero based, meaning that the first item in an array has index 0, the second item has index 1, and so on.

Pipe operators

The pipe operator separates two expressions. Each output from the expression on the left side is fed into the expression on the right side.

Variables

Variables are referenced by variable identifiers. A variable can be one of the following:

Variable definitions

Variables can be defined by using the following syntax:

Identity selector

The identity selector references the input of the current expression.

Variable identifiers

Object field access operator

Array / String field access operator

Array / String slice

Array / String / Object value iterator

Optional field access operators

Output concatenation operator

Grouping operator

String literals

Multiline strings

String interpolation

String escape sequences

The following sequences are valid inside string literals:

HEX Code Escape sequence Char
0x08 \b BS (backspace)
0x09 \t TAB
0x0a \n LF (line feed)
0x0c \f FF (form feed)
0x0d \r CR (carriage return)
0x22 \" "
0x27 \' '
0x2f \/ / (forward slash)
0x5c \\ \ (backslash)
0x60 \` ` (backtick)
0x00 - 0xFFFF \u<hex><hex><hex><hex> Unicode sequence, e.g. \u0040 equals @
  \(expression) See String interpolation

Numbers

Booleans

Null

Object constructors

Array constructors

Mathematical operations

Addition

Subtraction

Subtraction, Multiplication, Division, Remainder

Conditionals

Null coalescence

Assignment

Variable assignment

a.b = 1: {variable-selector}.path = {expression}

If

Comparison operators

Boolean operators

Error handling

Error suppression

Function definitions

Function calls

Comments

Further reading