Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/streams/to_json.ts>toJson

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function toJson
import { toJson } from "https://deno.land/std@0.220.0/streams/to_json.ts";

Converts a JSON-formatted ReadableSteam of strings or Uint8Arrays to an object. Works the same as Response.json.

Examples

Example 1

import { toJson } from "https://deno.land/std@0.220.0/streams/to_json.ts";

const stream = ReadableStream.from([JSON.stringify({ hello: "world" })]);
await toJson(stream); // { hello: "world" }

Parameters

readableStream: ReadableStream

Returns

Promise<unknown>