The rest of the body decoded as JSON into a T, with app.json_options. Content-Type: application/json (or +json) is required (415); a body that is not JSON is a 400 and one of
the wrong shape a 422, both naming the JSON path.
The value is built in the temporary allocator, like everything a request decodes: strings and
arrays in it are gone once the response is written, so copy_string what you keep.
read_json :: (body: *Body, $T: Type) -> (T, Http_Error)
The rest of the body decoded as JSON into a T, with app.json_options. Content-Type: application/json (or +json) is required (415); a body that is not JSON is a 400 and one of
the wrong shape a 422, both naming the JSON path.
The value is built in the temporary allocator, like everything a request decodes: strings and
arrays in it are gone once the response is written, so copy_string what you keep.
Parameters
- body: *Body
- $T: Type
Returns
- T
read_json :: (response: *Client_Response, $T: Type) -> (T, Client_Error)
The body decoded as a T (whatever the status: check response.status first). It is
Io.read_json over the response's body, so the body is decoded as it arrives; the limit of
max_response_size and the read-once rule are the same as for read_text. Strings in the
value are from the context allocator; free_json releases them.
Parameters
- response: *Client_Response
- $T: Type
Returns
- T