pub enum Json {
Null,
Bool(bool),
Int(i64),
Real(f64),
Text(String),
Array(Vec<Json>),
Object(Vec<(String, Json)>),
}Expand description
A JSON value.
An object keeps its pairs in the order they were written, because a result whose keys shuffle between runs cannot be compared byte for byte, and byte comparison is how everything else in this repository is checked.
Variants§
Null
null.
Bool(bool)
true or false.
Int(i64)
A number that arrived, or is being written, as an integer.
Real(f64)
A number with a fractional part or an exponent.
Text(String)
A string, already unescaped.
Array(Vec<Json>)
An array.
Object(Vec<(String, Json)>)
An object, in insertion order.
Implementations§
Source§impl Json
impl Json
Sourcepub fn get(&self, key: &str) -> Option<&Json>
pub fn get(&self, key: &str) -> Option<&Json>
Returns the value stored under a key, when this is an object that has one.
@param key - the member name
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Returns this value as a string, for the variants that have one.
A number or a boolean answers None rather than its rendering: a
parameter declared as text and given 7 is a caller’s mistake, and
quietly reading it as "7" hides the mistake until the SQL is wrong.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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