pub fn to_value<T: Serialize>(value: &T) -> Result<Value, Error>Expand description
Serializes a value into a Value.
The event data of the serialized values (such as formatting hints) is captured in the meta data of the values.
use std::collections::BTreeMap;
use deser::Order;
use deser_value::{to_value, value};
let map = BTreeMap::from([("b", 2), ("a", 1)]);
let value = to_value(&map).unwrap();
assert_eq!(value, value!({"a": 1, "b": 2}));
assert_eq!(value.as_map().unwrap().order(), Order::Sorted);To configure the serialization use the Serializer.