Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rfc9535/test_suite/results.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Total; Passed; Failed; Date
687; 652; 0; 2025-03-18 22:56:39
687; 652; 0; 2025-03-18 22:57:01
687; 652; 0; 2025-05-13 21:21:59
687; 652; 0; 2025-05-19 15:05:31
18 changes: 6 additions & 12 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@ pub type Parsed<T> = Result<T, JsonPathError>;
///
/// Returns a variant of [crate::JsonPathParserError] if the parsing operation failed.
pub fn parse_json_path(jp_str: &str) -> Parsed<JpQuery> {
if jp_str != jp_str.trim() {
Err(JsonPathError::InvalidJsonPath(
"Leading or trailing whitespaces".to_string(),
))
} else {
JSPathParser::parse(Rule::main, jp_str)
.map_err(Box::new)?
.next()
.ok_or(JsonPathError::UnexpectedPestOutput)
.and_then(next_down)
.and_then(jp_query)
}
JSPathParser::parse(Rule::main, jp_str)
.map_err(Box::new)?
.next()
.ok_or(JsonPathError::UnexpectedPestOutput)
.and_then(next_down)
.and_then(jp_query)
}

pub fn jp_query(rule: Pair<Rule>) -> Parsed<JpQuery> {
Expand Down
4 changes: 2 additions & 2 deletions src/parser/grammar/json_path_9535.pest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main = { SOI ~ jp_query ~ EOI }
main = ${ SOI ~ jp_query ~ EOI }
jp_query = {root ~ segments}
segments = {(S ~ segment)*}
segments = !{(S ~ segment)*}
segment = { child_segment | descendant_segment }
child_segment = { bracketed_selection | ("." ~ (wildcard_selector | member_name_shorthand)) }
bracketed_selection = { "[" ~ S ~ selector ~ (S ~ "," ~ S ~ selector)* ~ S ~ "]" }
Expand Down
Loading