Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class JsonParseStream
extends TransformStream<string, JsonValue>
import { JsonParseStream } from "https://deno.land/std@0.162.0/encoding/json/stream.ts";

Parse each chunk as JSON.

This can be used to parse JSON lines, NDJSON and JSON Text Sequences. Chunks consisting of spaces, tab characters, or newline characters will be ignored.

import { TextLineStream } from "https://deno.land/std@0.162.0/streams/mod.ts";
import { JsonParseStream } from "https://deno.land/std@0.162.0/encoding/json/stream.ts";

const url = "https://deno.land/std@0.162.0/encoding/testdata/json/test.jsonl";
const { body } = await fetch(url);

const readable = body!
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(new TextLineStream()) // or `new TextDelimiterStream(delimiter)`
  .pipeThrough(new JsonParseStream());

for await (const data of readable) {
  console.log(data);
}

Constructors

new
JsonParseStream(unnamed 0?: ParseStreamOptions)