unflatten
Function
unflatten — transform an array of key/value records into a record.
Synopsis
unflatten(val: [{key:string|[string],value:any}]) -> record
Description
The unflatten function converts the key/value records in array val
into
a single record. unflatten is the inverse of flatten, i.e., unflatten(flatten(r))
will produce a record identical to r
.
Examples
Simple:
values unflatten(this)
[{key:"a",value:1},{key:["b"],value:2}]
Loading...
echo '[{key:"a",value:1},{key:["b"],value:2}]' \
| super -s -c 'values unflatten(this)' -
Flatten to unflatten:
over flatten(this) into (
key[1] != "rm"
| values collect(this)
)
| values unflatten(this)
{a:1,rm:2}
Loading...
echo '{a:1,rm:2}' \
| super -s -c 'over flatten(this) into (
key[1] != "rm"
| values collect(this)
)
| values unflatten(this)' -