Skip to main content

$$unflatten

Accepts an object with dot separated field names and merges them into an hierarchical object.

Usage​

{
"$$unflatten": /* object */,
"target": /* target object */,
"path": ""
}
"$$unflatten([target],[path]):{input}"

Returns​

array

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryobjectYesObject with dot separated field names
targetobjectnullA target to merge into
pathstringnullThe root path in the target to merge into

Examples​

Input

Definition

Output

{
"a.a1": 123,
"a.a2.b.c": true,
"b": "bbb"
}
{
"$$unflatten": "$",
"path":"x",
"target": {
"y": 0
}
}
{
"y": 0,
"x": {
"a": {
"a1": 123,
"a2": {
"b": {
"c": true
}
}
},
"b": "bbb"
}
}
{
"a.a1": 123,
"a.a2.b.c": true,
"b": "bbb"
}
"$$unflatten:$"
{
"a": {
"a1": 123,
"a2": {
"3": {
"c": true
}
}
},
"b": "bbb"
}