[][src]Struct json::object::Object

pub struct Object { /* fields omitted */ }

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.

Methods

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]

Deprecated since 0.11.11:

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.

Important traits for Iter<'a>
pub fn iter(&self) -> Iter[src]

Important traits for IterMut<'a>
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_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl From<Object> for JsonValue[src]

impl PartialEq<Object> for JsonValue[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<Object> for &'a JsonValue[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<JsonValue> for Object[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<Object> for Object[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Debug for Object[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.

impl Index<String> for Object[src]

type Output = JsonValue

The returned type after indexing.

impl<'a> Index<&'a String> for Object[src]

type Output = JsonValue

The returned type after indexing.

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<'a> IndexMut<&'a String> for Object[src]

Auto Trait Implementations

impl Sync for Object

impl Send for Object

impl Unpin for Object

impl RefUnwindSafe for Object

impl UnwindSafe for Object

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]