pub enum Json {
Array(Vec<Json>),
Object(HashMap<String, Json>),
String(String),
Number(f64),
True,
False,
Null,
}
Expand description
Represents a JSON object
Variants§
Implementations§
source§impl Json
impl Json
sourcepub fn deserialize(text: impl AsRef<str>) -> Result<Json>
pub fn deserialize(text: impl AsRef<str>) -> Result<Json>
Deserializes the given string into a Json object
sourcepub fn deserialize_with_config(
text: impl AsRef<str>,
conf: JsonConfig,
) -> Result<Json>
pub fn deserialize_with_config( text: impl AsRef<str>, conf: JsonConfig, ) -> Result<Json>
Deserializes the given string into a Json object using the given JsonConfig
sourcepub fn serialize(&self, out: &mut dyn Write) -> Result
pub fn serialize(&self, out: &mut dyn Write) -> Result
Serializes the JSON object into a string
sourcepub fn get(&self, key: impl AsRef<str>) -> Option<&Json>
pub fn get(&self, key: impl AsRef<str>) -> Option<&Json>
Attempts to get a value of the given json object. If the json enum is not an Object variant, or if it doesn’t contain the key, returns None
sourcepub fn get_mut(&mut self, key: impl AsRef<str>) -> Option<&mut Json>
pub fn get_mut(&mut self, key: impl AsRef<str>) -> Option<&mut Json>
Same as [get], but with a mutable reference
sourcepub fn nth(&self, i: usize) -> Option<&Json>
pub fn nth(&self, i: usize) -> Option<&Json>
Attempts to get a value of the given json array. If the json enum is not an Array variant, or if it doesn’t contain the key, returns None
sourcepub fn nth_mut(&mut self, i: usize) -> Option<&mut Json>
pub fn nth_mut(&mut self, i: usize) -> Option<&mut Json>
Same as [nth], but with a mutable reference
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Json
impl RefUnwindSafe for Json
impl Send for Json
impl Sync for Json
impl Unpin for Json
impl UnwindSafe for Json
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