Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ndjson

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndjson

streaming newline delimited json parser + serializer

  • 1.4.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
437K
decreased by-53.08%
Maintainers
2
Weekly downloads
 
Created

What is ndjson?

The ndjson npm package is used for parsing and stringifying newline-delimited JSON (NDJSON) data. NDJSON is a convenient format for streaming JSON data, where each line is a valid JSON object. This package allows you to easily work with NDJSON data in Node.js applications.

What are ndjson's main functionalities?

Parsing NDJSON

This feature allows you to parse NDJSON data from a readable stream. The code sample reads NDJSON data from a file and parses each line into a JSON object, which is then logged to the console.

const ndjson = require('ndjson');
const fs = require('fs');

fs.createReadStream('data.ndjson')
  .pipe(ndjson.parse())
  .on('data', function(obj) {
    console.log('Parsed object:', obj);
  });

Stringifying NDJSON

This feature allows you to stringify JSON objects into NDJSON format. The code sample takes an array of JSON objects and writes them to a file in NDJSON format.

const ndjson = require('ndjson');
const fs = require('fs');

const data = [
  { name: 'Alice', age: 30 },
  { name: 'Bob', age: 25 }
];

const stringifyStream = ndjson.stringify();
stringifyStream.pipe(fs.createWriteStream('output.ndjson'));
data.forEach(item => stringifyStream.write(item));
stringifyStream.end();

Other packages similar to ndjson

Keywords

FAQs

Package last updated on 01 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc