to_bytes/
to_bytes.rs

1fn main() {
2    use nson::m;
3    use nson::Value;
4
5    let a = Value::I32(123);
6    println!("{:?}", a.to_bytes());
7
8    let m = m! {
9        "a": 123i32,
10        "b": {
11            "c": 456
12        }
13    };
14    println!("{:?}", m.to_bytes());
15    let m: Value = m.into();
16    println!("{:?}", m.to_bytes());
17
18    let a = 123;
19    let bytes = nson::encode::to_bytes(&a).unwrap();
20    println!("{:?}", bytes);
21
22    let b: i32 = nson::decode::from_bytes(&bytes).unwrap();
23    println!("{:?}", b);
24    assert_eq!(a, b);
25}