pub enum JsonValue {
Null,
Bool(bool),
Int(i64),
Double(f64),
String(String),
Array(Vec<JsonValue>),
Object(BTreeMap<String, JsonValue>),
}Expand description
A JSON value with integers and floats kept distinct.
Variants§
Null
JSON null.
Bool(bool)
A boolean.
Int(i64)
An integer.
Double(f64)
A floating-point number. Non-finite values (NaN, infinities) are not valid
JSON and serialize to null; avoid constructing them.
String(String)
A string.
Array(Vec<JsonValue>)
An array of values.
Object(BTreeMap<String, JsonValue>)
An object with string keys, kept sorted.
Implementations§
Source§impl JsonValue
impl JsonValue
Sourcepub fn object<const N: usize>(pairs: [(&str, JsonValue); N]) -> Self
pub fn object<const N: usize>(pairs: [(&str, JsonValue); N]) -> Self
Build an object from a fixed set of (key, value) pairs.
Sourcepub fn as_object(&self) -> Option<&BTreeMap<String, JsonValue>>
pub fn as_object(&self) -> Option<&BTreeMap<String, JsonValue>>
The object’s fields, if this is an object.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JsonValue
impl<'de> Deserialize<'de> for JsonValue
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for JsonValue
impl RefUnwindSafe for JsonValue
impl Send for JsonValue
impl Sync for JsonValue
impl Unpin for JsonValue
impl UnsafeUnpin for JsonValue
impl UnwindSafe for JsonValue
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