Trait serde_json::value::Index
[−]
[src]
pub trait Index: Sealed { }
A type that can be used to index into a serde_json::Value
.
The get
and get_mut
methods of Value
accept any type that
implements Index
, as does the square-bracket indexing operator. This
trait is implemented for strings which are used as the index into a JSON
map, and for usize
which is used as the index into a JSON array.
This trait is sealed and cannot be implemented for types outside of
serde_json
.
Examples
let data = json!({ "inner": [1, 2, 3] }); // Data is a JSON map so it can be indexed with a string. let inner = &data["inner"]; // Inner is a JSON array so it can be indexed with an integer. let first = &inner[0]; assert_eq!(first, 1);
Implementations on Foreign Types
impl Index for usize
[src]
impl Index for usize
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
[src]
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
[src]
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
[src]
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
impl Index for str
[src]
impl Index for str
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
[src]
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
[src]
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
[src]
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
impl Index for String
[src]
impl Index for String
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
[src]
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
[src]
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
[src]
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
impl<'a, T: ?Sized> Index for &'a T where
T: Index,
[src]
impl<'a, T: ?Sized> Index for &'a T where
T: Index,
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
[src]
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
[src]
fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value
[src]
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value