4 releases (2 breaking)
0.3.0 | May 16, 2023 |
---|---|
0.2.0 | May 16, 2023 |
0.1.1 | May 16, 2023 |
0.1.0 | May 16, 2023 |
#1971 in Encoding
46KB
396 lines
nyoom-json : json what goes nyoom
nyoom-json is a bare-bones streaming json generation library, built for specialized use cases and Just Going Fast ™️ it's also no-std!
credit where credit is due
nyoom-json borrows heavily in style from write-json, and takes its string escaping code from miniserde
examples
use nyoom_json::{Serializer, Null};
let mut out = String::new();
let mut ser = Serializer::new(&mut out);
let mut obj = ser.object();
obj.field("kind", "cat");
obj.field("has_been_fed", false);
obj.field("meow_decibels", 45);
obj.field("illness", Null); // good! mew :3
obj.end();
use nyoom_json::Serializer;
let mut out = String::new();
let mut ser = Serializer::new(&mut out);
let mut arr = ser.array();
arr.add(1);
arr.add(2);
arr.add("three");
arr.end();
ser.end();
use nyoom_json::{Serializer, UnescapedStr};
let mut out = String::with_capacity(64);
let mut ser = Serializer::new(&mut out);
let mut arr = ser.array();
arr.add_complex(|mut ser| {
let mut state = ser.object();
state.field(UnescapedStr::create("mew"), 3);
state.complex_field(UnescapedStr::create("meow"), |mut ser| {
let mut seq = ser.array();
seq.add(3);
seq.add(2);
});
});
arr.add("ny");
arr.end();
Dependencies
~315–790KB
~18K SLoC