pub enum JsonValue {
Null,
Bool(bool),
Number(JsonNumber),
String(String),
Array(Vec<JsonValue>),
Object(JsonObject),
}Expand description
An owned JSON value.
JSON has exactly six value kinds, so this enum is intentionally exhaustive —
you can match it without a wildcard arm.
Variants§
Null
null.
Bool(bool)
true or false.
Number(JsonNumber)
A number, preserving its exact source text.
String(String)
A string (decoded Unicode scalar values).
Array(Vec<JsonValue>)
An array.
Object(JsonObject)
An object with unique keys in insertion order.
Implementations§
Source§impl JsonValue
impl JsonValue
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true if this is JsonValue::Null.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the boolean if this is a JsonValue::Bool.
Sourcepub fn as_number(&self) -> Option<&JsonNumber>
pub fn as_number(&self) -> Option<&JsonNumber>
Returns the number if this is a JsonValue::Number.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the string if this is a JsonValue::String.
Sourcepub fn as_array(&self) -> Option<&[JsonValue]>
pub fn as_array(&self) -> Option<&[JsonValue]>
Returns the array if this is a JsonValue::Array.
Sourcepub fn as_object(&self) -> Option<&JsonObject>
pub fn as_object(&self) -> Option<&JsonObject>
Returns the object if this is a JsonValue::Object.
Trait Implementations§
impl StructuralPartialEq for JsonValue
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