pub enum Value {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<Value>),
Object(Map),
}Expand description
A self-describing JSON value.
Variants§
Null
null
Bool(bool)
true / false
Number(Number)
Number (lossless through i128 / u128, see Number).
String(String)
string
Array(Vec<Value>)
array
Object(Map)
object (insertion-ordered Map)
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
The mutable array reference, if this is an array.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut Map>
pub fn as_object_mut(&mut self) -> Option<&mut Map>
The mutable object reference, if this is an object.
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Get a value by key, mutable (objects only).
Sourcepub fn pointer(&self, pointer: &str) -> Option<&Value>
pub fn pointer(&self, pointer: &str) -> Option<&Value>
Locate a value by RFC 6901 JSON Pointer.
/a/b/0 descends into a -> b -> first array element; ~0 / ~1
escape ~ and /. The empty pointer returns self.
Sourcepub fn into_object(self) -> Option<Map>
pub fn into_object(self) -> Option<Map>
Consume self into a Map (if object).
Sourcepub fn into_array(self) -> Option<Vec<Value>>
pub fn into_array(self) -> Option<Vec<Value>>
Consume self into a Vec (if array).
Trait Implementations§
Source§impl<'de> NsonDeserialize<'de> for Value
impl<'de> NsonDeserialize<'de> for Value
Source§fn nextdecode_into<D: FormatDecoder<'de>>(
decoder: &mut D,
out: &mut DecodeSlot<Self>,
) -> Result<(), D::Error>
fn nextdecode_into<D: FormatDecoder<'de>>( decoder: &mut D, out: &mut DecodeSlot<Self>, ) -> Result<(), D::Error>
Decode into
out. Read moreSource§fn expecting() -> &'static str
fn expecting() -> &'static str
Human-readable description of the value this type decodes from. Read more
Source§fn nextdecode<D: FormatDecoder<'de>>(decoder: &mut D) -> Result<Self, D::Error>
fn nextdecode<D: FormatDecoder<'de>>(decoder: &mut D) -> Result<Self, D::Error>
Decode and return a value.
Source§impl NsonSchema for Value
impl NsonSchema for Value
Source§const SCHEMA: TypeSchema = TypeSchema::Opaque
const SCHEMA: TypeSchema = TypeSchema::Opaque
The compile-time structural description.
Source§impl NsonSerialize for Value
impl NsonSerialize for Value
Source§fn nextencode<E: FormatEncoder>(&self, e: &mut E) -> Result<(), E::Error>
fn nextencode<E: FormatEncoder>(&self, e: &mut E) -> Result<(), E::Error>
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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