jsonlines2json

1.0.0 • Public • Published

jsonlines-2-json

Convert CRLF or New Line Delimited JSON into valid JSON

build status

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);
  }));

Package Sidebar

Install

npm i jsonlines2json

Weekly Downloads

1

Version

1.0.0

License

BSD-3-Clause

Unpacked Size

5.16 kB

Total Files

8

Last publish

Collaborators

  • eugeneware