Function miniserde::json::to_string[][src]

pub fn to_string<T: ?Sized + Serialize>(value: &T) -> String

Serialize any serializable type into a JSON string.

#[macro_use]
extern crate miniserde;

use miniserde::json;

#[derive(MiniSerialize, Debug)]
struct Example {
    code: u32,
    message: String,
}

fn main() {
    let example = Example {
        code: 200,
        message: "reminiscent of Serde".to_owned(),
    };

    let j = json::to_string(&example);
    println!("{}", j);
}