Package Exports
- read-json-lines-sync
- read-json-lines-sync/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (read-json-lines-sync) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
read-json-lines-sync
Synchronous reader of a string containing many lines in JSON format
installation
with NPM:
npm install --save read-json-lines-syncor with yarn:
yarn add read-json-lines-syncusage
import readJsonLines from 'read-json-lines-sync';
// or alternative syntax:
// const readJsonLines = require('read-json-lines-sync').default;
const lines = `{"foo":"bar"}
{"foo2":"bar2"}
`;
const result = readJsonLines(lines);
expect(result).to.deep.equal([
{ foo: 'bar' },
{ foo2: 'bar2' },
]);specification
- It omits every line which isn't a valid JSON.
- For the remaining lines, it converts every line into an object.
- So it always returns an array (possibly an empty array if there's no line with a valid JSON).
