Skip to main content

get_with_parser

Function get_with_parser 

Source
pub fn get_with_parser<'a, S, C, T, P>(
    path: P,
    parser: &mut Parser<'a, S, C>,
) -> Result<T>
where S: Source + 'a, C: Config, T: Deserialize<'a>, P: IntoIterator, P::Item: JsonPointer,
Available on crate feature serde only.
Expand description

Skips to the given path and deserializes the type using the provided parser.

Same as get_from but takes parser as an argument. Useful in case you want to modify the default parsing behaviour.

ยงExample

use flexon::{Parser, serde::*, config::CTConfig};

let src = r#"{"one": 1 "two": 2}"#;
let config = CTConfig::new().optional_comma();
let mut parser = Parser::new_with(src, config);
let val: u8 = get_with_parser(["two"], &mut parser).unwrap();

assert_eq!(val, 2);