$$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​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | object | Yes | Any Object | |
target | object | null | A target to merge into | |
prefix | string | null | A prefix to add to the base | |
array_prefix | string | "$" | 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
}