# json-nd

> json-nd is a module that provides functions to parse and stringify newline-delimited JSON (NDJSON) data.

Latest version **1.0.0** (published 2023-06-15) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install json-nd
pnpm add json-nd
yarn add json-nd
bun add json-nd
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-06-15 |
| First published | 2023-06-15 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | DK |
| Maintainers | dk_thyms |
| Keywords | ndjson, ldjson |

## Links

- npm: https://www.npmjs.com/package/json-nd
- Repository: https://github.com/thyms/json-nd
- Homepage: git://github.com/thyms/json-nd.git
- Issues: git://github.com/thyms/json-nd.git
- npm.io page: https://npm.io/package/json-nd

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-06-15

## README

# json-nd

`NdJson` is a utility class for parsing and stringifying newline-delimited JSON (NDJSON) data.

## Installation

```bash
npm install json-nd
```

## Usage

### Parsing NDJSON

```typescript
import { NdJson } from 'json-nd';

const data = `
{"name":"John","age":30}
{"name":"Jane","age":25}
{"name":"Bob","age":40}
`;

const parsedData = NdJson.parse<{ name: string, age: number }>(data);
console.log(parsedData);
// Output: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }, { name: 'Bob', age: 40 }]
```

### Stringifying to NDJSON

```typescript
import { NdJson } from 'json-nd';

const jsonData = [
  { name: 'John', age: 30 },
  { name: 'Jane', age: 25 },
  { name: 'Bob', age: 40 }
];

const ndjsonData = NdJson.stringify(jsonData);
console.log(ndjsonData);
// Output:
// {"name":"John","age":30}
// {"name":"Jane","age":25}
// {"name":"Bob","age":40}
```

## API

### `NdJson.parse<T>(data: string): T[]`

Parses NDJSON data into an array of objects of type `T`.

- `data`: The NDJSON data to parse.
- Returns: An array of objects of type `T` parsed from the NDJSON data.

### `NdJson.stringify(data: any[]): string`

Converts an array of objects into NDJSON format.

- `data`: The array of objects to stringify.
- Returns: The NDJSON string representation of the input data.

## License

This project is licensed under the BSD-3-Clause.

---
_Source: https://npm.io/package/json-nd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
