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)
: (JSONValue | 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