Skip to main content

Convert a Node.js Readable to JSON

还没翻译译自英文(bun.com)本页 2 段都还没译

To convert a Node.js Readable stream to a JSON object in Bun, create a Response with the stream as the body, then call response.json().

import { Readable } from "stream";
const stream = Readable.from([JSON.stringify({ hello: "world" })]);
const json = await new Response(stream).json();
console.log(json); // { hello: "world" }
译文 © 2026 fanyi.dev · 原文 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)