jsonlines2json
v1.0.0
Published
Convert CRLF or New Line Delimited JSON into valid JSON
Downloads
5
Maintainers
Readme
jsonlines-2-json
Convert CRLF or New Line Delimited JSON into valid JSON
Motivation
Many online tools that deal with viewing and editing JSON don't work with New Line Delimited JSON. This module is both a command line tool as well as a module.
You can use this with jqi for example to play with ND JSON or JSON Data Ninja
Installation
This module is installed via npm:
$ npm i -g jsonlines2json
Example Usage
From the terminal
$ cat test/fixtures/test.json
{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]}
{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
{"name": "May", "wins": []}
{"name": "Deloise", "wins": [["three of a kind", "5♣"]]}
$ cat test/fixtures/test.json | jsonlines2json
[{"name":"Gilbert","wins":[["straight","7♣"],["one pair","10♥"]]},{"name":"Alexa","wins":[["two pair","4♠"],["two pair","9♠"]]},{"name":"May","wins":[]},{"name":"Deloise","wins":[["three of a kind","5♣"]]}]
As a module
const jsonlines2json = require('jsonlines2json');
const fs = require('fs');
const path = require('path');
fs.createReadStream(path.join(__dirname, 'fixtures', 'test.json'))
.pipe(jsonlines2Json())
.pipe(concat({ encoding: 'string' }, (data) => {
console.log(data);
}));