https://github.com/h4l/json_seq
Deno module for streams of individual JSON objects. RFC 7464 format. WHATWG Streams API.
https://github.com/h4l/json_seq
deno json rfc7464 whatwg-streams
Last synced: about 2 months ago
JSON representation
Deno module for streams of individual JSON objects. RFC 7464 format. WHATWG Streams API.
- Host: GitHub
- URL: https://github.com/h4l/json_seq
- Owner: h4l
- License: mit
- Created: 2021-12-14T08:18:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-22T17:44:20.000Z (over 4 years ago)
- Last Synced: 2025-11-29T01:18:22.699Z (7 months ago)
- Topics: deno, json, rfc7464, whatwg-streams
- Language: TypeScript
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# json_seq
A [Deno] module for working with streams of individual JSON objects, using the
json-seq format described in [RFC 7464].
[Deno]: https://deno.land/
[RFC 7464]: https://datatracker.ietf.org/doc/html/rfc7464
## Usage
```ts
// examples/print_stream_contents.ts
import { JsonSequenceDecoderStream } from "https://deno.land/x/json_seq@v0.1.0/mod.ts";
import { readableStreamFromReader } from "https://deno.land/std@0.117.0/streams/conversion.ts";
const jsonStream = readableStreamFromReader(Deno.stdin)
.pipeThrough(new JsonSequenceDecoderStream());
for await (const json of jsonStream) {
console.log(`JSON value: ${Deno.inspect(json)}`);
}
```
```sh
$ echo -e '\x1E{"message": "hi"}\n\x1E{"message": "bye"}\n' \
| deno run examples/print_stream_contents.ts
JSON value: { message: "hi" }
JSON value: { message: "bye" }
```
## Roadmap
- [x] Publish on deno.land
- [ ] Implement stream encoding
- [ ] Review the non-strict decoding behaviour and more closely follow the
lenient handling of malformed streams described in the RFC
- [ ] Maybe allow visibility of/control over malformed stream recovery actions
## Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)