pub fn to_string(input: &Value) -> Result<String, CanonicalJSONError>
Expand description

Serialize a JSON value to String

Examples

    to_string(&json!(null)); // returns "null"

    to_string(&json!("test")); // returns "test"

    to_string(&json!(10.0_f64.powf(21.0))); // returns "1e+21"

    to_string(&json!({
        "a": "a",
        "id": "1",
        "b": "b"
    })); // returns "{"a":"a","b":"b","id":"1"}"; (orders object keys)

    to_string(&json!(vec!["one", "two", "three"])); // returns "["one","two","three"]"