json-rust
json-rust copied to clipboard
Display strings as quoted and escaped JSON string
The Display behavior for strings is inconsistent with the behavior for other JsonValue variants. The others all display in JSON form.
#[macro_use]
extern crate json;
fn main() {
println!("{}", json::JsonValue::Null);
println!("{}", json::JsonValue::from(1.23));
println!("{}", json::JsonValue::from(true));
println!("{}", object!{ "code \n" => 200 });
println!("{}", array![ "one", "two \n" ]);
// :(
println!("{}", json::JsonValue::from("str \n"));
}