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.149.0/encoding/json/_parse.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.149.0/streams/mod.ts";
import { JSONParseStream } from "https://deno.land/std@0.149.0/encoding/json/stream.ts";

const url = "https://deno.land/std@0.149.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)