https://github.com/pingbird/json_stream
A package for converting objects to JSON asynchronously through a byte stream.
https://github.com/pingbird/json_stream
Last synced: 6 months ago
JSON representation
A package for converting objects to JSON asynchronously through a byte stream.
- Host: GitHub
- URL: https://github.com/pingbird/json_stream
- Owner: pingbird
- License: bsd-3-clause
- Created: 2023-02-07T02:28:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-08T00:33:58.000Z (over 3 years ago)
- Last Synced: 2025-06-10T11:12:53.016Z (about 1 year ago)
- Language: Dart
- Homepage: https://pub.dev/packages/json_stream
- Size: 7.81 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# json_stream
A package for converting objects to JSON asynchronously through a byte stream.
This package is useful for encoding extremely large objects that would consume too much memory with a standard
[JsonEncoder](https://api.dart.dev/dart-convert/JsonEncoder-class.html).
Basic example:
```dart
import 'dart:async';
import 'dart:io';
import 'package:json_stream/writer.dart';
Future 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),
}),
);
}
```