Skip to content

Array and object literals

You can build arrays and objects directly in an expression, without depending on the shape of the source document. Literals work anywhere a property-value expression does.

Square brackets enclose array elements. Elements can be literals (including nested arrays and objects), range variables, or method results.

{
"@x": "#valueOf($.some.path)",
"array": "[ 1, 'two', null, @x, #valueOf($.some.path) ]"
}

Curly braces enclose object properties. Property names must be string literals. Property values can be literals (including nested arrays and objects), range variables, or method results.

{
"@x": "#valueOf($.some.path)",
"object": "{ 'integerValue': 5, 'stringValue': 'test', 'booleanValue': true, 'rangeVariable': @x, 'methodCallResult': #valueOf($.some.path) }",
"nestedObject": "{ 'nested': { 'array': [ 1, 2, 3 ], 'object': { 'key': @x } } }"
}

Object literals are handy for passing parameters to #transformWith and for enriching results with #merge.