#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

#295 in Encoding

Download history 6728/week @ 2024-07-24 6766/week @ 2024-07-31 7063/week @ 2024-08-07 6454/week @ 2024-08-14 7180/week @ 2024-08-21 6796/week @ 2024-08-28 6767/week @ 2024-09-04 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 5550/week @ 2024-11-06

25,188 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