Skip to main content
To convert a Node.js Readable stream to a JSON object in Bun, you can create a new Response object with the stream as the body, then use response.json() to read the stream into a JSON object.
import {Readable} from 'stream';
const stream = Readable.from([JSON.stringify({hello: 'world'})]);
const json = await new Response(stream).json();
console.log(json); // { hello: "world" }
I