pub struct Object<'a> {
pub members: Vec<(RawStr<'a>, Value<'a>)>,
/* private fields */
}Expand description
A JSON object, with member order preserved.
Order is not cosmetic here: it is what lets a record be reproduced exactly, and it is how a caller can tell which vendor extension came where.
Fields§
§members: Vec<(RawStr<'a>, Value<'a>)>The members, in source order, duplicates included.
Implementations§
Source§impl<'a> Object<'a>
impl<'a> Object<'a>
Sourcepub fn get(&self, key: &str) -> Option<&Value<'a>>
pub fn get(&self, key: &str) -> Option<&Value<'a>>
The last member with this key, matching what Gson (the reference
verifier) and serde_json both do.
A duplicate key is separately reported as
DeviationKind::DuplicateKey, so choosing a resolution here never
hides the ambiguity.
Sourcepub fn extras<'s>(
&'s self,
known: &'s [&'s str],
) -> impl Iterator<Item = &'s (RawStr<'a>, Value<'a>)> + 's
pub fn extras<'s>( &'s self, known: &'s [&'s str], ) -> impl Iterator<Item = &'s (RawStr<'a>, Value<'a>)> + 's
Members whose key is not in known, in source order.
This is how vendor extension points are surfaced — at every level, not only the payload’s top level, because that is where they actually occur.
Trait Implementations§
impl<'a> Eq for Object<'a>
impl<'a> StructuralPartialEq for Object<'a>
Auto Trait Implementations§
impl<'a> Forget for Object<'a>
impl<'a> Freeze for Object<'a>
impl<'a> Move for Object<'a>
impl<'a> RefUnwindSafe for Object<'a>
impl<'a> Send for Object<'a>
impl<'a> Sync for Object<'a>
impl<'a> Unpin for Object<'a>
impl<'a> UnsafeUnpin for Object<'a>
impl<'a> UnwindSafe for Object<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more