summaryrefslogtreecommitdiffstats
path: root/vendor/write-json/README.md
blob: ddb95aaaf2ecf09d1f60216fbd9fdff878162ab1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# write-json


Simple {dependency,trait,macro}-less JSON serialization


```rust
let mut buf = String::new();

{
    let mut obj = write_json::object(&mut buf);
    obj.string("name", "Peter").number("favorite number", 92.0);
    obj.array("films")
        .string("Drowning By Numbers")
        .string("A Zed & Two Noughts");
    obj.null("suitcase");
}

assert_eq!(
    buf,
    r#"{"name":"Peter","favorite number":92,"films":["Drowning By Numbers","A Zed & Two Noughts"],"suitcase":null}"#
)
```