[−][src]Struct jsonp::BackingJson
Convenience wrapper around the library core functions for raw Json, removing some of the generic noise from function signatures.
Implementations
impl<'a> BackingJson<'a>
[src]
pub fn new(borrow: &'a RawJson) -> Self
[src]
Instantiate a wrapper around the given borrowed raw Json.
pub fn with(borrow: &'a RawJson, p: Pointer) -> Self
[src]
Instantiate a wrapper around the given borrowed raw Json and pointer.
pub fn dotted<'de, T>(&self, pointer: &str) -> Result<T, Error> where
T: Deserialize<'de>,
'a: 'de,
[src]
T: Deserialize<'de>,
'a: 'de,
See the documentation of Pointer::dotted
.
Example
use {jsonp::{BackingJson, Segment}, serde_json::from_str}; let json = from_str(r#"{"outer": {"array": [0, "one", true]}}"#).unwrap(); let one: &str = BackingJson::new(json).dotted("outer.array.1").unwrap(); assert!(one == "one");
pub fn pattern<'de, T>(&self, pointer: &str, pattern: &str) -> Result<T, Error> where
T: Deserialize<'de>,
'a: 'de,
[src]
T: Deserialize<'de>,
'a: 'de,
See the documentation of Pointer::with_pattern
.
Example
use {jsonp::{BackingJson, Segment}, serde_json::from_str}; let json = from_str(r#"{"outer": {"array": [0, "one", true]}}"#).unwrap(); let is_true: bool = BackingJson::new(json).pattern("outer array 2", " ").unwrap(); assert!(is_true);
pub fn pointer<'de, 'p, I, T>(&self, pointers: I) -> Result<T, Error> where
I: IntoIterator<Item = Segment<'p>>,
T: Deserialize<'de>,
'a: 'de,
[src]
I: IntoIterator<Item = Segment<'p>>,
T: Deserialize<'de>,
'a: 'de,
See the documentation for Pointer::with_segments
.
Example
use {jsonp::{BackingJson, Segment}, serde_json::from_str}; let json = from_str(r#"{"outer": {"array": [0, 1, 2, 3]}}"#).unwrap(); let segments = &["outer", "array"]; let array: Vec<i8> = BackingJson::new(json) .pointer(segments.into_iter().copied().map(Segment::lazy)) .unwrap(); assert_eq!(&array, &[0, 1, 2, 3]);
Trait Implementations
impl<'a> Clone for BackingJson<'a>
[src]
fn clone(&self) -> BackingJson<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for BackingJson<'a>
[src]
impl<'a> From<&'a RawValue> for BackingJson<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for BackingJson<'a>
impl<'a> Send for BackingJson<'a>
impl<'a> Sync for BackingJson<'a>
impl<'a> Unpin for BackingJson<'a>
impl<'a> UnwindSafe for BackingJson<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,