Skip to main content

$$flatten

Flattens a JsonObject into a flat dot seperated list of entries.

Usage​

{
"$$flatten": /* object */,
"target": /* target object */,
"prefix": "",
"array_prefix": "\\$"
}
"$$flatten([target],[prefix],[array_prefix]):{input}"

Returns​

array

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryobjectYesAny Object
targetobjectnullA target to merge into
prefixstringnullA prefix to add to the base
array_prefixstring"$"Sets how array elements should be prefixed, leave null to not flatten arrays

Examples​

Input

Definition

Output

{
"a1": 123,
"a2": [ 1, 2 ,3, { "c": true } ]
}
{
"$$flatten": {
"a": "$",
"b": "bbb"
}
}
{
"a.a1": 123,
"a.a2.$0": 1,
"a.a2.$1": 2,
"a.a2.$2": 3,
"a.a2.$3.c": true,
"b": "bbb"
}
{
"a1": 123,
"a2": [ 1, 2 ]
}
"$$flatten('#null',x,''):$"
{
"x.a1": 123,
"x.a2.0": 1,
"x.a2.1": 2
}