Struct json_writer::PrettyJSONWriter
source · 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 StringResult
Implementations§
source§impl PrettyJSONWriter<'_>
impl PrettyJSONWriter<'_>
sourcepub fn new<'a>(buffer: &'a mut String) -> PrettyJSONWriter<'a>
pub fn new<'a>(buffer: &'a mut String) -> PrettyJSONWriter<'a>
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
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
Auto Trait Implementations§
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