#json #serialization #macro #numbers #string #obj

write-json

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

4 releases

0.1.4 Dec 31, 2023
0.1.2 Aug 1, 2020
0.1.1 Aug 1, 2020
0.1.0 Aug 1, 2020

#372 in Encoding

Download history 6055/week @ 2024-09-11 6312/week @ 2024-09-18 6619/week @ 2024-09-25 5956/week @ 2024-10-02 6523/week @ 2024-10-09 6413/week @ 2024-10-16 6276/week @ 2024-10-23 5955/week @ 2024-10-30 5584/week @ 2024-11-06 5496/week @ 2024-11-13 5734/week @ 2024-11-20 6329/week @ 2024-11-27 7018/week @ 2024-12-04 7133/week @ 2024-12-11 6503/week @ 2024-12-18 4782/week @ 2024-12-25

26,605 downloads per month
Used in ungrammar2json

MIT/Apache

8KB
197 lines

write-json

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

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}"#
)

lib.rs:

Simple dependency-less macro-less trait-less JSON serialization.

Example

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}"#
)

No runtime deps