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 JsonT
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]
type Item = HttpResponse
The associated item which can be returned.
type Error = Error
The associated error which can be returned.
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error>
[src]
Convert itself to Reply
or Error
.