Skip to main content
Module

std/streams/mod.ts>toJson

The Deno Standard Library
Go to Latest
function toJson
import { toJson } from "https://deno.land/std@0.223.0/streams/mod.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.223.0/streams/to_json.ts";

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

Parameters

readableStream: ReadableStream

Returns

Promise<unknown>