Skip to content

Commit

Permalink
update jsonpath-lib to 0.3.0, removing all atty deps
Browse files Browse the repository at this point in the history
  • Loading branch information
OlsonZacheryFS committed Jul 31, 2023
1 parent a0b50d8 commit d6e7386
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 70 deletions.
62 changes: 3 additions & 59 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions lib/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ ether = { path = "../either" }
futures = "0.3"
http = "0.2"
itertools = "0.10"
# pinned to 0.2.3 because newer versions made a semver incompatible change by making `Node` no longer
# public, which we depend on https://github.com/freestrings/jsonpath/issues/36
jsonpath_lib = "=0.2.3"
jsonpath_lib = "0.3.0"
percent-encoding = "2"
pest = "2"
pest_derive = "2"
Expand All @@ -33,4 +31,4 @@ log = "0.4"
[dev-dependencies]
maplit = "1"
test_common = { path = "../test_common" }
tokio = "1"
tokio = "1"
14 changes: 7 additions & 7 deletions lib/config/src/expression_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ impl Join {
#[derive(Clone)]
pub(super) struct JsonPath {
provider: String,
selector: Arc<json_path::Node>,
selector: Arc<json_path::Compiled>,
marker: Marker,
}

Expand Down Expand Up @@ -784,7 +784,7 @@ impl JsonPath {
} else {
format!("$.{json_path}")
};
let json_path = json_path::Parser::compile(&json_path).map_err(|_| {
let json_path = json_path::Compiled::compile(&json_path).map_err(|_| {
ExecutingExpressionError::InvalidFunctionArguments("json_path", marker)
})?;
let j = JsonPath {
Expand All @@ -809,12 +809,12 @@ impl JsonPath {
}

fn evaluate_to_vec(&self, d: &json::Value) -> Vec<json::Value> {
let mut selector = json_path::Selector::new();
selector
.compiled_path(&self.selector)
.value(d)
.select_as()
self.selector
.select(d)
.unwrap_or_default()
.into_iter()
.cloned()
.collect()
}

pub(super) fn evaluate<'a, 'b: 'a>(&'b self, d: Cow<'a, json::Value>) -> Cow<'a, json::Value> {
Expand Down

0 comments on commit d6e7386

Please sign in to comment.