Skip to content

Commit

Permalink
add support for double qs
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Zhguchev committed Apr 29, 2024
1 parent a7f3e2c commit 5ad23c3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
55 changes: 29 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
* **`0.1.0`**
* Initial implementation
* Initial implementation
* **`0.1.1`**
* Technical improvements
* Technical improvements
* **`0.1.2`**
* added a trait to obtain the result from value
* added a method to get the cloned as Value
* change the name of the general method*
* added a trait to obtain the result from value
* added a method to get the cloned as Value
* change the name of the general method*
* **`0.1.4`**
* add an ability to use references instead of values
* fix some clippy issues
* add an ability to use references instead of values
* fix some clippy issues
* **`0.1.5`**
* correct grammar for `$.[..]`
* correct grammar for `$.[..]`
* **`0.1.6`**
* add logical OR and logical And to filters
* fix bugs with objects in filters
* add internal macros to generate path objects
* add logical OR and logical And to filters
* fix bugs with objects in filters
* add internal macros to generate path objects
* **`0.2.0`**
* add json path value as a result for the library
* add functions (size)
* change a logical operator `size` into function `size()`
* add json path value as a result for the library
* add functions (size)
* change a logical operator `size` into function `size()`
* **`0.2.1`**
* changed the contract for length() function.
* changed the contract for length() function.
* **`0.2.2`**
* add ..*
* add ..*
* **`0.2.5`**
* build for tags
* build for tags
* **`0.2.6`**
* make parser mod public
* make parser mod public
* **`0.3.0`**
* introduce the different behaviour for empty results and non-existing result
* introduce the different behaviour for empty results and non-existing result
* **`0.3.2`**
* make jsonpath inst cloneable.
* make jsonpath inst cloneable.
* **`0.3.3`**
* fix a bug with the logical operators
* fix a bug with the logical operators
* **`0.3.4`**
* add a result as a path
* add a result as a path
* **`0.3.5`**
* add `!` negation operation in filters
* allow using () in filters
* add `!` negation operation in filters
* allow using () in filters
* **`0.5`**
* add config for jsonpath
* add an option to add a regex cache for boosting performance
* add config for jsonpath
* add an option to add a regex cache for boosting performance
* **`0.5.1`**
* add double quotes for the expressions (before it was only possible to use single quotes)
* add Debug on the JsonPathFinder


2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "jsonpath-rust"
description = "The library provides the basic functionality to find the set of the data according to the filtering query."
version = "0.5.0"
version = "0.5.1"
authors = ["BorisZhguchev <[email protected]>"]
edition = "2018"
license-file = "LICENSE"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ mod tests {
let json: Box<Value> =
Box::new(json!([{"verb": "TEST"},{"verb": "TEST"}, {"verb": "RUN"}]));
let path: Box<JsonPathInst> = Box::from(
JsonPathInst::from_str("$.[?(@.verb == 'RUN1')]").expect("the path is correct"),
JsonPathInst::from_str("$.[?(@.verb == \"RUN1\")]").expect("the path is correct"),
);
let finder = JsonPathFinder::new(json, path);

Expand Down
2 changes: 1 addition & 1 deletion src/parser/grammar/json_path.pest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ word = _{ ('a'..'z' | 'A'..'Z')+ }
specs = _{ "_" | "-" | "/" | "\\" | "#" }
number = @{"-"? ~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) ~ ("." ~ ASCII_DIGIT+)? ~ (^"e" ~ ("+" | "-")? ~ ASCII_DIGIT+)?}

string_qt = ${ "\'" ~ inner ~ "\'" }
string_qt = ${ ("\'" ~ inner ~ "\'") | ("\"" ~ inner ~ "\"") }
inner = @{ char* }
char = _{
!("\"" | "\\" | "\'") ~ ANY
Expand Down
4 changes: 2 additions & 2 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ mod tests {
test_failed("[]");
test("[-1,-2]", vec![path!(idx!(idx - 1, -2))]);
test_failed("[abc,bcd]");
test_failed("[\"abc\",\"bcd\"]");
test("[\"abc\",\"bcd\"]", vec![path!(idx!("abc", "bcd"))]);
}

#[test]
fn array_start_test() {
test(
"$.[?(@.verb== 'TEST')]",
"$.[?(@.verb== \"TEST\")]",
vec![
path!($),
path!(idx!(?filter!(op!(chain!(path!(@,path!("verb")))),"==",op!("TEST")))),
Expand Down

0 comments on commit 5ad23c3

Please sign in to comment.