#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

#356 in Encoding

Download history 6444/week @ 2024-08-15 7191/week @ 2024-08-22 6832/week @ 2024-08-29 6749/week @ 2024-09-05 6044/week @ 2024-09-12 6354/week @ 2024-09-19 6420/week @ 2024-09-26 6218/week @ 2024-10-03 6329/week @ 2024-10-10 6470/week @ 2024-10-17 6260/week @ 2024-10-24 5795/week @ 2024-10-31 5743/week @ 2024-11-07 5455/week @ 2024-11-14 5699/week @ 2024-11-21 5560/week @ 2024-11-28

23,198 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