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

pub struct Object { /* fields omitted */ }
Expand description

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

Create a new, empty instance of Object. Empty Object performs no allocation until a value is inserted into it.

Create a new Object with memory preallocated for capacity number of entries.

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.

👎 Deprecated since 0.11.11:

Was only meant for internal use

Attempts to remove the value behind key, if successful will return the JsonValue stored behind the key.

Wipe the Object clear. The capacity will remain untouched.

Prints out the value as JSON string.

Pretty prints out the value as JSON string. Takes an argument that’s number of spaces to indent new blocks with.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

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");
}

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

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);
}

Performs the mutable indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.