Function jsonxf::pretty_print
[−]
[src]
pub fn pretty_print(json_string: &str, indent: &str) -> Result<String, String>
Pretty-prints a string of JSON-encoded data.
Valid inputs produce valid outputs. However, this function does not perform JSON validation, and is not guaranteed to either reject or accept invalid input.
The indent
parameter sets the string used to indent pretty-printed
output; e.g., " "
or "\t"
.
Examples:
assert_eq!( jsonxf::pretty_print("{\"a\":1,\"b\":2}", " ").unwrap(), "{\n \"a\": 1,\n \"b\": 2\n}\n" ); assert_eq!( jsonxf::pretty_print("{\"empty\":{},\n\n\n\n\n\"one\":[1]}", "\t").unwrap(), "{\n\t\"empty\": {},\n\t\"one\": [\n\t\t1\n\t]\n}\n" );