[][src]Macro reign_derive::json

json!() { /* proc-macro */ }

Shorthand notation for returning a json response.

Examples

Serialize into JSON and send the given value

This example is not tested
use reign::prelude::*;

// User implements serde::Serialize
let user = User {
    name: "John"
};

json!(user)

You can also specify a status code

This example is not tested
use reign::prelude::*;

json!(user, status = 201)