New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ndjson-to-json-text

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndjson-to-json-text

Convert ndjson to json text without JSON parsing.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

ndjson-to-json-text Build Status

Convert ndjson text to JSON text without JSON parsing.

This library convert ndjson text to json text.

{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}
{"id":3,"name":"Carol"}

to

[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"},{"id":3,"name":"Carol"}]

Purpose

  • Just convert ndjson(text file) to json(text file)
    • You should JSON.parse the result json text outside of this library
  • No use JSON.parse in this library
    • It is a cost

Install

Install with npm:

npm install ndjson-to-json-text

Usage

/**
 * Convert ndjson text to JSON text
 * The return value is a string of JSON array text
 * @param ndjsonText
 */
export declare function ndjsonToJsonText(ndjsonText: string): string;

Example

const jsonText = ndjsonToJsonText(
`{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}
{"id":3,"name":"Carol"}`)
console.log(jsonText);
// [{"id":1,"name":"Alice"},{"id":2,"name":"Bob"},{"id":3,"name":"Carol"}]
const json = JSON.parse(jsonText);
// actual json object!!

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test
# Update snapshot
npm run updateSnapshot

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request :D

Author

License

MIT © azu

Keywords

converter

FAQs

Package last updated on 28 Feb 2019

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