[][src]Function ajson::get

pub fn get(json: &str, path: &str) -> Option<Value>

get value from JSON string with the specified path, it is relatively loose and can tolerate some illegal JSON.

let data = r#"{"name": "ajson"}"#;
let v = ajson::get(data, "name").unwrap();
assert_eq!(v.as_str(), "ajson");

If the given JSON is not a valid JSON, then ajson will try to get the value from the first JSON array or map it finds.

let data = r#"someinvalidstring{"name": "ajson"}"#;
let v = ajson::get(data, "name").unwrap();
assert_eq!(v.as_str(), "ajson");

If there is no valid JSON array or map in the given JSON, get returns None.

let data = r#"someinvalidstring"#;
let v = ajson::get(data, "name").unwrap();