pub enum Json {
Null,
Bool(bool),
Number(f64),
String(String),
Array(Vec<Json>),
Object(BTreeMap<String, Json>),
}Expand description
A JSON value.
Variants§
Null
null
Bool(bool)
true or false
Number(f64)
Any JSON number, held as f64.
String(String)
A string, already unescaped.
Array(Vec<Json>)
An array.
Object(BTreeMap<String, Json>)
An object. Ordered so that output is deterministic.
Implementations§
Source§impl Json
impl Json
Sourcepub fn as_array(&self) -> Option<&[Json]>
pub fn as_array(&self) -> Option<&[Json]>
Read as a slice of elements, if this is an array.
Returns None for a non-array rather than an empty slice, so a caller
can tell “not an array” from “an array with nothing in it” — a
distinction that matters when the value came from somewhere else.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Read as an f64, if this is a number.
Json::as_i64 truncates; this does not, so a caller that needs the
value as written has somewhere to get it.
Trait Implementations§
impl StructuralPartialEq for Json
Auto Trait Implementations§
impl Freeze for Json
impl RefUnwindSafe for Json
impl Send for Json
impl Sync for Json
impl Unpin for Json
impl UnsafeUnpin 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