flatten-json-pipe
v0.0.2
Published
Pipe JSON in, get it flattened on the way out
Downloads
5
Readme
#flatten-json-pipe
Pipe JSON in, get it flattened on the way out.
##Run
Install with npm.
$ npm install flatten-json-pipe -g
Pipe through passing an optional delimiter
.
$ echo '{"A":{"name":"Peter"},"B":{"val":[\"a\",\"b\"]}}' | flatten-json-pipe '.'
You get the following back:
{
"A.name": "Peter",
"B.val.0": "a",
"B.val.1": "b"
}
##Source
_ = require 'highland'
ndjson = require 'ndjson'
flat = require 'flat'
module.exports = (delimiter='.') ->
through = (obj) -> flat obj, { delimiter }
_.pipeline.apply _, [
do _
do ndjson.parse
_.map through
do ndjson.stringify
]