Convert ndjson to json text without JSON parsing.
npm install ndjson-to-json-textConvert 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
`json`
[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"},{"id":3,"name":"Carol"}]
- Just convert ndjson(text file) to json(text file)
- You should JSON.parse the result json text outside of this libraryJSON.parse
- No use in this library
- It is a cost
Install with npm:
npm install ndjson-to-json-text
`ts`
/**
* 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;
`js{"id":1,"name":"Alice"}
const jsonText = ndjsonToJsonText(
{"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!!
- madnight/ndjson-to-json: Converts NDJSON to JSON
- It only work on Node.js
See Releases page.
Install devDependencies and Run npm test:
npm test
# Update snapshot
npm run updateSnapshot
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit commit -am 'Add some feature'
3. Commit your changes: git push origin my-new-feature`
4. Push to the branch:
5. Submit a pull request :D
MIT © azu