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

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

#192 in Encoding

Download history 7473/week @ 2024-04-14 7008/week @ 2024-04-21 6896/week @ 2024-04-28 6182/week @ 2024-05-05 6093/week @ 2024-05-12 7139/week @ 2024-05-19 6717/week @ 2024-05-26 7119/week @ 2024-06-02 7509/week @ 2024-06-09 7117/week @ 2024-06-16 7115/week @ 2024-06-23 6533/week @ 2024-06-30 6591/week @ 2024-07-07 7246/week @ 2024-07-14 6862/week @ 2024-07-21 6669/week @ 2024-07-28

28,447 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