diff --git a/src/grammer.pest b/src/grammer.pest index 515102d..46666c4 100644 --- a/src/grammer.pest +++ b/src/grammer.pest @@ -69,4 +69,4 @@ query = _{SOI ~ "$" ~ root? ~ EOI} simple_query = _{SOI ~ "$" ~ simple_root ~ EOI} -WHITESPACE = _{ " " } \ No newline at end of file +WHITESPACE = _{ " " | "\r\n" | "\n" | "\r" | "\t" } \ No newline at end of file diff --git a/src/json_path.rs b/src/json_path.rs index fd07b22..d187749 100644 --- a/src/json_path.rs +++ b/src/json_path.rs @@ -21,6 +21,8 @@ pub struct QueryCompilationError { message: String, } +impl std::error::Error for QueryCompilationError {} + impl std::fmt::Display for QueryCompilationError { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!( diff --git a/tests/filter.rs b/tests/filter.rs index 7758d67..dc8598c 100644 --- a/tests/filter.rs +++ b/tests/filter.rs @@ -319,3 +319,12 @@ fn unimplemented_in_filter() { json!([]), ); } + +#[test] +fn whitespace() { + select_and_then_compare( + "$\n[\r?\t(\r\n@\r.a == 1)]", + json!({"a": 1}), + json!([{"a" : 1}]), + ); +}