Io module

read_json

procedure · 1 overloadSource

Reads a document to the end of reader and decodes it as a T: the same value or error as from_json(T, text) for the same bytes, however they arrive (a pipe written in small pieces, a socket). The pieces are gathered in one buffer that is freed before this returns. A reader that fails gives a .READ error naming the Io_Error; a document over options.max_size is a .LIMIT error and the rest of the stream is left unread. The reader is not closed.

read_json :: (
    reader: Reader,
    $T: Type,
    options := Json.Json_Options.{}
) -> (T, Json.Json_Error)

Reads a document to the end of reader and decodes it as a T: the same value or error as from_json(T, text) for the same bytes, however they arrive (a pipe written in small pieces, a socket). The pieces are gathered in one buffer that is freed before this returns. A reader that fails gives a .READ error naming the Io_Error; a document over options.max_size is a .LIMIT error and the rest of the stream is left unread. The reader is not closed.

Parameters

reader: Reader
$T: Type
options := Json.Json_Options.{}

Returns

T