json-flat
Flatters any JSON properties returning an array of concatenated properties.
Usage
This module might be used from CLI or requiring it.
From CLI
This module might be used from CLI. It parses a given JSON file and returns a list of properties concatenated. Expects these parameters:
--path
: Path to a JSON file.--separator
(Optional): Separator to be used to concatenate properties
$> node json-flat --path ./test.jsonfoo.barfoo.bar.string $> node json-flat --path ./test.json --separator _foo_barfoo_bar_string
From require
This module might be imported in other module using require
. It parses a given JSON Object and returns an array with all properties concatenated, for example:
var jsonFlat = _json = JSON; // With default separatorjsonFlat;// Prints:// foo.number// foo.bar.string // With a given separatorjsonFlat;// Prints:// foo_number// foo_bar_string