ndjson 0.2.2 copy "ndjson: ^0.2.2" to clipboard
ndjson: ^0.2.2 copied to clipboard

Tiny and simple ndjson parser library for Dart. No external dependencies.

ndjson parser for Dart #

Pub Version Pub Version

Tiny and simple ndjson parser library for Dart. No external dependencies.

Installation #

dependencies:
  ndjson: ^<latest-version>

Import:

import 'package:ndjson/ndjson.dart';

Usage #

The usage is pretty straightforward:

import 'package:ndjson/ndjson.dart';

// Your ndjson stream.
final Stream<String|List<int>> ndjsonStream = ...

// A new stream that will parse all chunks and emit events 
// for each new json object (not ndjson chunks).
final Stream<NdjsonLine> parsedNdjson = ndjsonStream.parseNdjson();

// Using converter functions:
final Stream<Dummy> ndjson = ndjsonSource.parseNdjsonWithConverter<Dummy>(
  whenMap: Dummy.fromJson,
);

Supported ndjson types are:

  • Stream<List<int>>.
  • Stream<Uint8List>.
  • Stream<String>.

Any list-like ndjson source can be converted to Stream using:

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).

1
likes
140
pub points
23%
popularity

Publisher

verified publisheralexrintt.io

Tiny and simple ndjson parser library for Dart. No external dependencies.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

Funding

Consider supporting this project:

donate.alexrintt.io
github.com

License

MIT (LICENSE)

More

Packages that depend on ndjson