Function to_string

Source
pub fn to_string<T>(value: &T) -> String
where T: ?Sized + Serialize,
Expand description

Serialize any serializable type into a JSON string.

use miniserde::{json, Serialize};

#[derive(Serialize, 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);
}