[−][src]Function jsonpath_lib::select_as_str
pub fn select_as_str(
json_str: &str,
path: &str
) -> Result<String, JsonPathError>
It is the same to select
function but it return the result as string.
extern crate jsonpath_lib as jsonpath; #[macro_use] extern crate serde_json; let ret = jsonpath::select_as_str(r#" { "school": { "friends": [ {"name": "친구1", "age": 20}, {"name": "친구2", "age": 20} ] }, "friends": [ {"name": "친구3", "age": 30}, {"name": "친구4"} ] } "#, "$..friends[0]").unwrap(); assert_eq!(ret, r#"[{"name":"친구3","age":30},{"name":"친구1","age":20}]"#);