RefValue serde 구현. bump up version. 0.1.5

This commit is contained in:
freestrings
2019-03-18 10:59:08 +09:00
parent 482c957003
commit b24a8c18a9
33 changed files with 949 additions and 629 deletions

View File

@ -15,6 +15,13 @@ fn read_json(path: &str) -> Value {
serde_json::from_str(contents.as_str()).unwrap()
}
fn read_contents(path: &str) -> String {
let mut f = std::fs::File::open(path).unwrap();
let mut contents = String::new();
f.read_to_string(&mut contents).unwrap();
contents
}
#[test]
fn compile() {
let mut template = jsonpath::compile("$..friends[2]");
@ -66,4 +73,19 @@ fn select() {
"price" : 8.99
}]);
assert_eq!(json, ret);
}
#[test]
fn select_str() {
let json_str = read_contents("./benches/example.json");
let result_str = jsonpath::select_str(&json_str, "$..book[2]").unwrap();
let ret = json!([{
"category" : "fiction",
"author" : "Herman Melville",
"title" : "Moby Dick",
"isbn" : "0-553-21311-3",
"price" : 8.99
}]);
let json: Value = serde_json::from_str(&result_str).unwrap();
assert_eq!(json, ret);
}