pub fn to_vec<'facet, T>(
value: &T,
) -> Result<Vec<u8>, SerializeError<JsonSerializeError>>Expand description
Serialize a value to JSON bytes.
ยงExample
use facet::Facet;
use facet_json::to_vec;
#[derive(Facet)]
struct Point { x: i32, y: i32 }
let point = Point { x: 10, y: 20 };
let bytes = to_vec(&point).unwrap();
assert_eq!(bytes, br#"{"x":10,"y":20}"#);