Dev Helpers
← Back

Parse a streamed JSON document

Parse a streamed JSON document using Node.js.

Open this example in the interactive library

Source code

import {
  Readable,
  Writable,
  Transform,
  PassThrough,
  isReadable,
  isWritable,
} from "node:stream";
import { text, json, arrayBuffer } from "node:stream/consumers";
import { pipeline, finished } from "node:stream/promises";
console.log(await json(Readable.from(['{"n":', "7}"])));

Sample output

{ n: 7 }