https://github.com/alexcmgit/ndjson.dart
Tiny and small library for parsing ndjson.
https://github.com/alexcmgit/ndjson.dart
dart dev ndjson parser pub stream
Last synced: 24 days ago
JSON representation
Tiny and small library for parsing ndjson.
- Host: GitHub
- URL: https://github.com/alexcmgit/ndjson.dart
- Owner: alexcmgit
- License: mit
- Created: 2023-04-07T15:23:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-11T15:31:25.000Z (about 2 years ago)
- Last Synced: 2025-04-03T14:22:05.934Z (26 days ago)
- Topics: dart, dev, ndjson, parser, pub, stream
- Language: Dart
- Homepage: https://pub.dev/packages/ndjson
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ndjson parser for Dart
[](https://pub.dev/packages/ndjson) [](https://pub.dev/packages/ndjson)
Tiny and simple ndjson parser library for Dart. No external dependencies.
## Installation
```yaml
dependencies:
ndjson: ^
```Import:
```dart
import 'package:ndjson/ndjson.dart';
```## Usage
The usage is pretty straightforward:
```dart
import 'package:ndjson/ndjson.dart';// Your ndjson stream.
final Stream> ndjsonStream = ...// A new stream that will parse all chunks and emit events
// for each new json object (not ndjson chunks).
final Stream parsedNdjson = ndjsonStream.parseNdjson();// Using converter functions:
final Stream ndjson = ndjsonSource.parseNdjsonWithConverter(
whenMap: Dummy.fromJson,
);
```---
Supported ndjson types are:
- `Stream>`.
- `Stream`.
- `Stream`.---
Any list-like ndjson source can be converted to `Stream` using:
```dart
Stream.fromIterable(ndjsonList);
```**You must be aware that using ndjson as list is the same as a regular json (you lose all ndjson performance benefits).**