pub struct Map<K, V> { /* fields omitted */ }
Represents a JSON key/value type.
Makes a new empty Map with the given initial capacity.
Clears the map, removing all values.
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.
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.
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.
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.
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.
pub fn entry<S>(&mut self, key: S) -> Entry where S: Into<String>, | [src] |
Gets the given key's corresponding entry in the map for in-place
manipulation.
Returns the number of elements in the map.
Returns true if the map contains no elements.
Gets an iterator over the entries of the map.
Gets a mutable iterator over the entries of the map.
Gets an iterator over the keys of the map.
Gets an iterator over the values of the map.
Gets an iterator over mutable values of the map.
Convert map (with string keys) to Value
use serde_json::{Map, Value};
let mut m = Map::new();
m.insert("Lorem".to_string(), "ipsum".into());
let x: Value = m.into();
type Item = (&'a String, &'a Value)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
type Item = (&'a String, &'a mut Value)
The type of the elements being iterated over.
type IntoIter = IterMut<'a>
Which kind of iterator are we turning this into?
Extends a collection with the contents of an iterator. Read more
Returns the "default value" for a type. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
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,
}
type Output = Value
The returned type after indexing.
Performs the indexing (container[index]
) operation.
Mutably access an element of this map. Panics if the given key is not
present in the map.
map["key"] = json!("value");
Performs the mutable indexing (container[index]
) operation.
Serialize this value into the given Serde serializer. Read more
Deserialize this value from the given Serde deserializer. Read more
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
type Owned = T
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
type Error = !
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static