Http module

expect_json

procedure · 1 overloadSource

The body decoded as JSON into a T. The status must be status, or 2xx when it is left out, and the Content-Type JSON. On failure the value is empty. The strings in it are allocated with the context allocator; a test may leave them.

expect_json :: (
    response: Client_Response,
    $T: Type,
    status := 0,
    loc := #caller_location
) -> T

The body decoded as JSON into a T. The status must be status, or 2xx when it is left out, and the Content-Type JSON. On failure the value is empty. The strings in it are allocated with the context allocator; a test may leave them.

Parameters

response: Client_Response
$T: Type
status := 0
the exact status wanted. 0 accepts any 2xx.
loc := #caller_location

Returns

T

See also