pub enum JsonValue {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<JsonValue>),
Object(Vec<(String, JsonValue)>),
}Expand description
A JSON document that remembers the order its object keys came in.
Variants§
Null
Bool(bool)
Number(Number)
String(String)
Array(Vec<JsonValue>)
Object(Vec<(String, JsonValue)>)
Implementations§
Source§impl JsonValue
impl JsonValue
Sourcepub fn parse(text: &str) -> Result<Self, Error>
pub fn parse(text: &str) -> Result<Self, Error>
Parse JSON text, keeping object keys in document order.
Sourcepub fn get(&self, key: &str) -> Option<&JsonValue>
pub fn get(&self, key: &str) -> Option<&JsonValue>
The member named key, if this is an object that has one. On a
duplicate key the first wins, matching nlohmann::json’s parser.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Whether this is an object with a member named key.
pub fn as_object(&self) -> Option<&[(String, JsonValue)]>
pub fn as_array(&self) -> Option<&[JsonValue]>
pub fn as_str(&self) -> Option<&str>
pub fn as_bool(&self) -> Option<bool>
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
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more