pub fn array<F>(builder: F) -> ArrayBuilderwhere
F: FnOnce(&mut ArrayBuilder),
Expand description
let json = jsonway::object(|json| {
json.set("first_name", "Luke");
json.set("last_name", "Skywalker");
json.object("info", |json| {
json.set("homeworld", "Tatooine");
json.set("born", "19 BBY");
json.set("died", "Between 45 ABY and 137 ABY");
});
json.array("masters", |json| {
json.push("Obi-Wan Kenobi");
json.push("Yoda");
json.push("Joruus C'baoth (Briefly)");
json.push("Darth Sidious (Briefly)");
});
}).unwrap();
assert_eq!(json.get("first_name").unwrap().as_str().unwrap(), "Luke");
assert_eq!(json.get("last_name").unwrap().as_str().unwrap(), "Skywalker");
assert!(json.get("info").unwrap().is_object());
assert!(json.get("masters").unwrap().is_array());
Create and return new ListBuilder