#[repr(C)]pub struct Json {
pub value_type: JsonType,
pub internal: JsonInternal,
}Expand description
A generic JSON value that can hold any JSON type
Fields§
§value_type: JsonTypeThe type of this JSON value
internal: JsonInternalInternal storage - interpretation depends on value_type For objects/arrays, this contains serialized data
Implementations§
Source§impl Json
impl Json
Sourcepub fn integer(value: i64) -> Self
pub fn integer(value: i64) -> Self
Create an integer JSON value.
Note: the value is stored as f64 internally, so i64 values with
magnitude greater than 2^53 will lose precision silently.
Sourcepub fn as_bool(&self) -> OptionBool
pub fn as_bool(&self) -> OptionBool
Get as boolean (returns None if not a bool)
Sourcepub fn as_i64(&self) -> OptionI64
pub fn as_i64(&self) -> OptionI64
Get as integer (returns None if not a number or not an integer)
Sourcepub fn as_string(&self) -> OptionString
pub fn as_string(&self) -> OptionString
Get as string (returns None if not a string)
Sourcepub fn raw_string(&self) -> &str
pub fn raw_string(&self) -> &str
Get the raw internal string value (for arrays/objects this is the serialized JSON)
Trait Implementations§
Source§impl Display for Json
Note: the Display output is meant for human-readable / debug display.
String values are quoted but not JSON-escaped (no backslash escaping
of embedded quotes, newlines, etc.). Use to_json_string() (requires
the serde-json feature) when valid JSON output is needed.
impl Display for Json
Note: the Display output is meant for human-readable / debug display.
String values are quoted but not JSON-escaped (no backslash escaping
of embedded quotes, newlines, etc.). Use to_json_string() (requires
the serde-json feature) when valid JSON output is needed.
Source§impl Extend<Json> for JsonVec
impl Extend<Json> for JsonVec
Source§fn extend<T: IntoIterator<Item = Json>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Json>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)