flat-stream
Object stream that flattens every object pipe through it. It is based on the module flat.
It includes an NDJSON CLI, which you can install with
npm install flat-stream -g
.
Usage
Optional options are directly passed to the flat
function from this module.
There is a safe
option for preserving arrays.
var flatten = safe: trueflattenflatten flatten
CLI Usage
The CLI takes Newline Seperated JSON from Stdin and flattens them to Stdout. Options can be passed in as shown in the example.
Given a file data.ndjson
{"A":{"a":1}}
{"A":{"a":2}, "B": [1,2,3]}
the command
flat-stream --safe < data.ndjson
will print
{"A.a":1}
{"A.a":2,"B":[1,2,3]}