Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 689 Bytes

flatten.md

File metadata and controls

26 lines (20 loc) · 689 Bytes

Function

flatten — transform a record into a flattened array.

Synopsis

flatten(val: record) -> [{key:[string],value:<any>}]

Description

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.

Examples

echo '{a:1,b:{c:"foo"}}' | super -z -c 'yield flatten(this)' -

=>

[{key:["a"],value:1},{key:["b","c"],value:"foo"}]