pub fn to_value<T>(value: T) -> Result<Value>
where T: Serialize,
Expand description

Serialize T to crate::value::JsoncValue

§Examples

use serde::Serialize;
#[derive(Serialize)]
struct Product {
    name: String,
    price: u32,
}
let target = Product { name: "candy".to_string(), price: 100 };
let product = json_with_comments::to_value(target).unwrap();
assert_eq!(product, json_with_comments::jsonc!({ "name": "candy", "price": 100 }));