pub enum Json {
Null,
Bool(bool),
Num(f64),
Str(String),
Array(Vec<Json>),
Object(BTreeMap<String, Json>),
}Expand description
A JSON value.
Variants§
Implementations§
Source§impl Json
impl Json
pub fn str<S: Into<String>>(s: S) -> Json
pub fn array(items: Vec<Json>) -> Json
pub fn object() -> Json
Sourcepub fn set<K: Into<String>>(self, key: K, value: Json) -> Json
pub fn set<K: Into<String>>(self, key: K, value: Json) -> Json
Insert into an object (no-op if this isn’t an object). Chainable.
Sourcepub fn push(self, value: Json) -> Json
pub fn push(self, value: Json) -> Json
Push onto an array (no-op if this isn’t an array). Chainable.
Sourcepub fn to_string_compact(&self) -> String
pub fn to_string_compact(&self) -> String
Serialize compactly (single line).
Sourcepub fn to_string_pretty(&self) -> String
pub fn to_string_pretty(&self) -> String
Serialize with two-space indentation.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Json
impl Freeze for Json
impl Move 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