Struct serde_json::Map [] [src]

pub struct Map<K, V> { /* fields omitted */ }

Represents a JSON key/value type.

Methods

impl Map<String, Value>
[src]

[src]

Makes a new empty Map.

[src]

Makes a new empty Map with the given initial capacity.

[src]

Clears the map, removing all values.

[src]

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

[src]

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

[src]

Returns a mutable reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

[src]

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical.

[src]

Removes a key from the map, returning the value at the key if the key was previously in the map.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

[src]

Gets the given key's corresponding entry in the map for in-place manipulation.

[src]

Returns the number of elements in the map.

[src]

Returns true if the map contains no elements.

Important traits for Iter<'a>
[src]

Gets an iterator over the entries of the map.

Important traits for IterMut<'a>
[src]

Gets a mutable iterator over the entries of the map.

Important traits for Keys<'a>
[src]

Gets an iterator over the keys of the map.

Important traits for Values<'a>
[src]

Gets an iterator over the values of the map.

Trait Implementations

impl Default for Map<String, Value>
[src]

[src]

Returns the "default value" for a type. Read more

impl Clone for Map<String, Value>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Map<String, Value>
[src]

[src]

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

1.0.0
[src]

This method tests for !=.

impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
    String: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

Access an element of this map. Panics if the given key is not present in the map.

match *val {
    Value::String(ref s) => Some(s.as_str()),
    Value::Array(ref arr) => arr[0].as_str(),
    Value::Object(ref map) => map["type"].as_str(),
    _ => None,
}

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<'a, Q: ?Sized> IndexMut<&'a Q> for Map<String, Value> where
    String: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

Mutably access an element of this map. Panics if the given key is not present in the map.

map["key"] = json!("value");

[src]

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

impl Debug for Map<String, Value>
[src]

[src]

Formats the value using the given formatter. Read more

impl Serialize for Map<String, Value>
[src]

[src]

Serialize this value into the given Serde serializer. Read more

impl Deserialize for Map<String, Value>
[src]

[src]

Deserialize this value from the given Serde deserializer. Read more

impl FromIterator<(String, Value)> for Map<String, Value>
[src]

[src]

Creates a value from an iterator. Read more

impl Extend<(String, Value)> for Map<String, Value>
[src]

[src]

Extends a collection with the contents of an iterator. Read more

impl<'a> IntoIterator for &'a Map<String, Value>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<'a> IntoIterator for &'a mut Map<String, Value>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl IntoIterator for Map<String, Value>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl From<Map<String, Value>> for Value
[src]

[src]

Convert map (with string keys) to Value

Examples

use serde_json::{Map, Value};

let mut m = Map::new();
m.insert("Lorem".to_string(), "ipsum".into());
let x: Value = m.into();