flatten — transform a record into a flattened array.
flatten(val: record) -> [{key:[string],value:<any>}]
The flatten function returns an array of records [{key:[string],value:<any>}]
where key
is a string array of the path of each record field of val
and
value
is the corresponding value of that field.
If there are multiple types for the leaf values in val
, then the array value
inner type is a union of the record types present.
echo '{a:1,b:{c:"foo"}}' | super -z -c 'yield flatten(this)' -
=>
[{key:["a"],value:1},{key:["b","c"],value:"foo"}]