pub struct PrettyJSONWriter<'a> {
pub buffer: &'a mut String,
/* private fields */
}
Expand description
Formats JSON in a human-readable format with whitespace, newlines, and indentation.
Fields§
§buffer: &'a mut String
Result
Implementations§
Source§impl PrettyJSONWriter<'_>
impl PrettyJSONWriter<'_>
Sourcepub fn new(buffer: &mut String) -> PrettyJSONWriter<'_>
pub fn new(buffer: &mut String) -> PrettyJSONWriter<'_>
Creates a new human-readable formatter with two spaces for indentation.
Sourcepub fn with_indent<'a>(
buffer: &'a mut String,
indent: &'a str,
) -> PrettyJSONWriter<'a>
pub fn with_indent<'a>( buffer: &'a mut String, indent: &'a str, ) -> PrettyJSONWriter<'a>
Creates a new formatter using indent
for indentation.
Trait Implementations§
Source§impl JSONWriter for PrettyJSONWriter<'_>
impl JSONWriter for PrettyJSONWriter<'_>
Source§fn json_begin_object(&mut self)
fn json_begin_object(&mut self)
Called at the start of writing an object. Writes the opening bracket
Source§fn json_end_object(&mut self, empty: bool)
fn json_end_object(&mut self, empty: bool)
Called after writing all key-value pairs of an object. Read more
Source§fn json_begin_array(&mut self)
fn json_begin_array(&mut self)
Called at the start of writing an array.
Source§fn json_end_array(&mut self, empty: bool)
fn json_end_array(&mut self, empty: bool)
Called after writing all items of an array. Read more
Source§fn json_begin_array_value(&mut self, first: bool)
fn json_begin_array_value(&mut self, first: bool)
Called before each key-value pair in an object and each item in an array.
Source§fn json_object_key(&mut self, key: &str, first: bool)
fn json_object_key(&mut self, key: &str, first: bool)
writes a comma when not first entry, escapes and writes the key and a colon
Source§fn json_string(&mut self, value: &str)
fn json_string(&mut self, value: &str)
Quotes and escapes the given string and writes the result to output with delimiting quotes.
Source§fn json_string_part(&mut self, value: &str)
fn json_string_part(&mut self, value: &str)
Quotes and escapes the given string and writes the result to output without delimiting quotes.
Source§fn json_fragment(&mut self, value: &str)
fn json_fragment(&mut self, value: &str)
write a raw json fragment
Source§fn json_number_f64(&mut self, value: f64)
fn json_number_f64(&mut self, value: f64)
Converts number to string and writes it. Writes null for NaN and infinity
Source§fn json_number_str(&mut self, value: &str)
fn json_number_str(&mut self, value: &str)
Writes a number that has already been converted to string
Source§fn json_begin_string(&mut self)
fn json_begin_string(&mut self)
Writes a double-quote. Read more
Source§fn json_end_string(&mut self)
fn json_end_string(&mut self)
Writes a double-quote. Read more
Auto Trait Implementations§
impl<'a> Freeze for PrettyJSONWriter<'a>
impl<'a> RefUnwindSafe for PrettyJSONWriter<'a>
impl<'a> Send for PrettyJSONWriter<'a>
impl<'a> Sync for PrettyJSONWriter<'a>
impl<'a> Unpin for PrettyJSONWriter<'a>
impl<'a> !UnwindSafe for PrettyJSONWriter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more