ResponseJSON¶
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
Constructors¶
create¶
Returns¶
- ResponseJSON val^
Public Functions¶
apply¶
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.
Parameters¶
- response: HTTPResponse val
Returns¶
- (JSONValue | JSONParseError val)
eq¶
Parameters¶
- that: ResponseJSON val
Returns¶
- Bool val
ne¶
Parameters¶
- that: ResponseJSON val
Returns¶
- Bool val