json_stream 1.0.0 json_stream: ^1.0.0 copied to clipboard
A package for converting objects to JSON asynchronously to a byte stream.
json_stream #
A package for converting objects to JSON asynchronously to a byte stream.
This package is useful for encoding extremely large objects that would consume too much memory with a standard JsonEncoder.
Basic example:
import 'dart:async';
import 'dart:io';
import 'package:json_stream/writer.dart';
Future<void> main() async {
await stdout.addStream(
JsonStreamWriter.convert({
'numbers': Stream.periodic(
const Duration(milliseconds: 100),
(i) => '$i',
).take(10),
'letters': Stream.periodic(
const Duration(milliseconds: 100),
(i) => '${String.fromCharCode(i + 0x61)}',
).take(26),
}),
);
}