[−][src]Struct serde_json::Map
Represents a JSON key/value type.
Methods
impl Map<String, Value>
[src]
impl Map<String, Value>
pub fn new() -> Self
[src]
pub fn new() -> Self
Makes a new empty Map.
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn with_capacity(capacity: usize) -> Self
Makes a new empty Map with the given initial capacity.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clears the map, removing all values.
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
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.
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
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.
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
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.
pub fn insert(&mut self, k: String, v: Value) -> Option<Value>
[src]
pub fn insert(&mut self, k: String, v: Value) -> Option<Value>
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.
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
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]
pub fn entry<S>(&mut self, key: S) -> Entry where
S: Into<String>,
Gets the given key's corresponding entry in the map for in-place manipulation.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in the map.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true if the map contains no elements.
ⓘImportant traits for Iter<'a>pub fn iter(&self) -> Iter
[src]
pub fn iter(&self) -> Iter
Gets an iterator over the entries of the map.
ⓘImportant traits for IterMut<'a>pub fn iter_mut(&mut self) -> IterMut
[src]
pub fn iter_mut(&mut self) -> IterMut
Gets a mutable iterator over the entries of the map.
ⓘImportant traits for Keys<'a>pub fn keys(&self) -> Keys
[src]
pub fn keys(&self) -> Keys
Gets an iterator over the keys of the map.
ⓘImportant traits for Values<'a>pub fn values(&self) -> Values
[src]
pub fn values(&self) -> Values
Gets an iterator over the values of the map.
ⓘImportant traits for ValuesMut<'a>pub fn values_mut(&mut self) -> ValuesMut
[src]
pub fn values_mut(&mut self) -> ValuesMut
Gets an iterator over mutable values of the map.
Trait Implementations
impl From<Map<String, Value>> for Value
[src]
impl From<Map<String, Value>> for Value
fn from(f: Map<String, Value>) -> Self
[src]
fn from(f: Map<String, Value>) -> Self
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();
impl<'a> IntoIterator for &'a Map<String, Value>
[src]
impl<'a> IntoIterator for &'a Map<String, Value>
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?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a> IntoIterator for &'a mut Map<String, Value>
[src]
impl<'a> IntoIterator for &'a mut Map<String, Value>
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?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl IntoIterator for Map<String, Value>
[src]
impl IntoIterator for Map<String, Value>
type Item = (String, Value)
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl Clone for Map<String, Value>
[src]
impl Clone for Map<String, Value>
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Extend<(String, Value)> for Map<String, Value>
[src]
impl Extend<(String, Value)> for Map<String, Value>
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (String, Value)>,
[src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (String, Value)>,
Extends a collection with the contents of an iterator. Read more
impl Default for Map<String, Value>
[src]
impl Default for Map<String, Value>
impl PartialEq<Map<String, Value>> for Map<String, Value>
[src]
impl PartialEq<Map<String, Value>> for Map<String, Value>
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Debug for Map<String, Value>
[src]
impl Debug for Map<String, Value>
fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
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.
fn index(&self, index: &Q) -> &Value
[src]
fn index(&self, index: &Q) -> &Value
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]
impl<'a, Q: ?Sized> IndexMut<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = json!("value");
fn index_mut(&mut self, index: &Q) -> &mut Value
[src]
fn index_mut(&mut self, index: &Q) -> &mut Value
Performs the mutable indexing (container[index]
) operation.
impl FromIterator<(String, Value)> for Map<String, Value>
[src]
impl FromIterator<(String, Value)> for Map<String, Value>
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = (String, Value)>,
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = (String, Value)>,
Creates a value from an iterator. Read more
impl Serialize for Map<String, Value>
[src]
impl Serialize for Map<String, Value>
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Map<String, Value>
[src]
impl<'de> Deserialize<'de> for Map<String, Value>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<K, V> Send for Map<K, V> where
K: Send,
V: Send,
impl<K, V> Send for Map<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for Map<K, V> where
K: Sync,
V: Sync,
impl<K, V> Sync for Map<K, V> where
K: Sync,
V: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<I> IntoIterator for I where
I: Iterator,
[src]
impl<I> IntoIterator for I where
I: Iterator,
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?
fn into_iter(self) -> I
[src]
fn into_iter(self) -> I
Creates an iterator from a value. Read more
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,