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.
fun box apply(
response: HTTPResponse val)
: (JsonObject val | JsonArray val | String val |
I64 val | F64 val | Bool val |
None val | JsonParseError val)
Parameters¶
- response: HTTPResponse val
Returns¶
- (JsonObject val | JsonArray val | String val | I64 val | F64 val | Bool val | None val | JsonParseError val)
eq¶
Parameters¶
- that: ResponseJSON val
Returns¶
- Bool val
ne¶
Parameters¶
- that: ResponseJSON val
Returns¶
- Bool val