Skip to content

ResponseJSON

[Source]

Parse the body of an HTTPResponse as JSON.

Returns the parsed JsonValue on success, or JsonParseError if the body is not valid JSON. This is deliberately minimal — users then use JsonNav, JsonLens, pattern matching, or whatever access pattern they prefer.

use json = "json"

match ResponseJSON(response)
| let value: json.JsonValue =>
  // work with the parsed JSON
| let err: json.JsonParseError =>
  env.out.print("Parse error: " + err.string())
end
primitive val ResponseJSON

Constructors

create

[Source]

new val create()
: ResponseJSON val^

Returns


Public Functions

apply

[Source]

Parse response.body as JSON.

Converts the body bytes to a String and parses with JsonParser.parse(). Returns JsonParseError if the body is empty or contains invalid JSON.

fun box apply(
  response: HTTPResponse val)
: (JsonObject val | JsonArray val | String val | 
    I64 val | F64 val | Bool val | 
    None val | JsonParseError val)

Parameters

Returns


eq

[Source]

fun box eq(
  that: ResponseJSON val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: ResponseJSON val)
: Bool val

Parameters

Returns