Struct json::object::Object [−][src]
A binary tree implementation of a string -> JsonValue map. You normally don’t
have to interact with instances of Object, much more likely you will be
using the JsonValue::Object variant, which wraps around this struct.
Implementations
impl Object[src]
pub fn new() -> Self[src]
Create a new, empty instance of Object. Empty Object performs no
allocation until a value is inserted into it.
pub fn with_capacity(capacity: usize) -> Self[src]
Create a new Object with memory preallocated for capacity number
of entries.
pub fn insert(&mut self, key: &str, value: JsonValue)[src]
Insert a new entry, or override an existing one. Note that key has
to be a &str slice and not an owned String. The internals of
Object will handle the heap allocation of the key if needed for
better performance.
pub fn override_last(&mut self, value: JsonValue)[src]
Was only meant for internal use
pub fn get(&self, key: &str) -> Option<&JsonValue>[src]
pub fn get_mut(&mut self, key: &str) -> Option<&mut JsonValue>[src]
pub fn remove(&mut self, key: &str) -> Option<JsonValue>[src]
Attempts to remove the value behind key, if successful
will return the JsonValue stored behind the key.
pub fn len(&self) -> usize[src]
pub fn is_empty(&self) -> bool[src]
pub fn clear(&mut self)[src]
Wipe the Object clear. The capacity will remain untouched.
pub fn iter(&self) -> Iter<'_>ⓘ[src]
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘ[src]
pub fn dump(&self) -> String[src]
Prints out the value as JSON string.
pub fn pretty(&self, spaces: u16) -> String[src]
Pretty prints out the value as JSON string. Takes an argument that’s number of spaces to indent new blocks with.
Trait Implementations
impl Clone for Object[src]
fn clone(&self) -> Self[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for Object[src]
impl From<Object> for JsonValue[src]
impl<K: AsRef<str>, V: Into<JsonValue>> FromIterator<(K, V)> for Object[src]
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self[src]
impl<'a> Index<&'a String> for Object[src]
type Output = JsonValue
The returned type after indexing.
fn index(&self, index: &String) -> &JsonValue[src]
impl<'a> Index<&'a str> for Object[src]
Implements indexing by &str to easily access object members:
Example
let value = object!{ foo: "bar" }; if let JsonValue::Object(object) = value { assert!(object["foo"] == "bar"); }
type Output = JsonValue
The returned type after indexing.
fn index(&self, index: &str) -> &JsonValue[src]
impl Index<String> for Object[src]
type Output = JsonValue
The returned type after indexing.
fn index(&self, index: String) -> &JsonValue[src]
impl<'a> IndexMut<&'a String> for Object[src]
impl<'a> IndexMut<&'a str> for Object[src]
Implements mutable indexing by &str to easily modify object members:
Example
let value = object!{}; if let JsonValue::Object(mut object) = value { object["foo"] = 42.into(); assert!(object["foo"] == 42); }
impl IndexMut<String> for Object[src]
impl PartialEq<JsonValue> for Object[src]
fn eq(&self, other: &JsonValue) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<Object> for JsonValue[src]
impl<'a> PartialEq<Object> for &'a JsonValue[src]
impl PartialEq<Object> for Object[src]
Auto Trait Implementations
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,