Struct actix_web::Json [] [src]

pub struct Json<T: Serialize>(pub T);

Json response helper

The Json type allows you to respond with well-formed JSON data: simply return a value of type Json where T is the type of a structure to serialize into JSON. The type T must implement the Serialize trait from serde.

#[derive(Serialize)]
struct MyObj {
    name: String,
}

fn index(req: HttpRequest) -> Result<Json<MyObj>> {
    Ok(Json(MyObj{name: req.match_info().query("name")?}))
}

Trait Implementations

impl<T: Serialize> Responder for Json<T>
[src]

The associated item which can be returned.

The associated error which can be returned.

[src]

Convert itself to Reply or Error.

Auto Trait Implementations

impl<T> Send for Json<T> where
    T: Send

impl<T> Sync for Json<T> where
    T: Sync