Skip to main content

JSONWriter

Trait JSONWriter 

Source
pub trait JSONWriter {
Show 15 methods // Required methods fn json_string(&mut self, value: &str); fn json_string_part(&mut self, value: &str); fn json_fragment(&mut self, value: &str); // Provided methods fn json_null(&mut self) { ... } fn json_bool(&mut self, value: bool) { ... } fn json_number_f64(&mut self, value: f64) { ... } fn json_number_str(&mut self, value: &str) { ... } fn json_begin_object(&mut self) { ... } fn json_end_object(&mut self, _empty: bool) { ... } fn json_begin_array(&mut self) { ... } fn json_end_array(&mut self, _empty: bool) { ... } fn json_begin_string(&mut self) { ... } fn json_end_string(&mut self) { ... } fn json_begin_array_value(&mut self, first: bool) { ... } fn json_object_key(&mut self, key: &str, first: bool) { ... }
}
Expand description

Writer trait for custom formatting and output

You most likely want to use JSONObjectWriter or JSONArrayWriter instead of using this directly

Required Methods§

Source

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)

Quotes and escapes the given string and writes the result to output without delimiting quotes.

Source

fn json_fragment(&mut self, value: &str)

write a raw json fragment

Provided Methods§

Source

fn json_null(&mut self)

Writes null

Source

fn json_bool(&mut self, value: bool)

Writes true or false

Source

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)

Writes a number that has already been converted to string

Source

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)

Called after writing all key-value pairs of an object.

empty is true when the object contains no key-value pairs.

Source

fn json_begin_array(&mut self)

Called at the start of writing an array.

Source

fn json_end_array(&mut self, _empty: bool)

Called after writing all items of an array.

empty is true when the array contains no items.

Source

fn json_begin_string(&mut self)

Writes a double-quote.

Called when creating a JSONStringWriter

Source

fn json_end_string(&mut self)

Writes a double-quote.

Called when dropping a JSONStringWriter

Source

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)

writes a comma when not first entry, escapes and writes the key and a colon

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl JSONWriter for String

Source§

fn json_begin_object(&mut self)

Called at the start of writing an object.

Source§

fn json_end_object(&mut self, _empty: bool)

Called after writing all key-value pairs of an object.

empty is true when the object contains no key-value pairs.

Source§

fn json_begin_array(&mut self)

Called at the start of writing an array.

Source§

fn json_end_array(&mut self, _empty: bool)

Called after writing all items of an array.

empty is true when the array contains no items.

Source§

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)

Called before each key-value pair in an object and each item in an array.

Source§

fn json_string(&mut self, value: &str)

Source§

fn json_string_part(&mut self, value: &str)

Source§

fn json_fragment(&mut self, value: &str)

Source§

fn json_begin_string(&mut self)

Source§

fn json_end_string(&mut self)

Implementors§