pub enum Json {
Null,
Bool(bool),
Number(String),
String(String),
Array(Vec<Json>),
Object(Vec<(String, Json)>),
}Variants§
Null
Bool(bool)
Number(String)
The number exactly as written: no float ever holds it.
String(String)
Array(Vec<Json>)
Object(Vec<(String, Json)>)
Keys in the order they were written.
Implementations§
Source§impl Json
impl Json
pub fn parse(text: &str) -> Result<Json, BadJson>
pub fn get(&self, key: &str) -> Option<&Json>
pub fn as_str(&self) -> Option<&str>
Sourcepub const fn as_bool(&self) -> Option<bool>
pub const fn as_bool(&self) -> Option<bool>
true or false; None for anything else, a "true" string too.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
A whole non-negative number, as the venue writes counts and ids.
pub fn as_array(&self) -> Option<&[Json]>
pub fn as_object(&self) -> Option<&[(String, Json)]>
pub const fn kind(&self) -> &'static str
Sourcepub fn compact(&self) -> String
pub fn compact(&self) -> String
One line, no spaces: what JSON.stringify writes, byte for byte.
Sourcepub fn to_msgpack(&self) -> Result<Value, Unpackable>
pub fn to_msgpack(&self) -> Result<Value, Unpackable>
The msgpack value this hashes as, keys in the order they were written.
Sourcepub fn to_action(&self) -> Result<Map, Unpackable>
pub fn to_action(&self) -> Result<Map, Unpackable>
The action map an L1 signature is over. Only an object is one.
Trait Implementations§
impl Eq for Json
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.