Module rouille_ng::input::json[][src]

Parsing JSON data in the body of a request.

Returns an error if the content-type of the request is not JSON, if the JSON is malformed, or if a field is missing or fails to parse.

Example


fn route_handler(request: &Request) -> Response {
    #[derive(Deserialize)]
    struct Json {
        field1: String,
        field2: i32,
    }

    let json: Json = try_or_400!(rouille_ng::input::json_input(request));
    Response::text(format!("field1's value is {}", json.field1))
}

Enums

JsonError

Error that can happen when parsing the JSON input.

Functions

json_input

Attempts to parse the request’s body as JSON.