diff --git a/src/lib.rs b/src/lib.rs index 1d11ede..ce687dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,7 +99,7 @@ //! [`there`]: https://goessner.net/articles/JsonPath/ pub use parser::model::JsonPath; -use parser::JsonPathParserError; +pub use parser::JsonPathParserError; use serde_json::Value; use std::fmt::Debug; use std::ops::Deref; @@ -263,10 +263,10 @@ macro_rules! jp_v { /// Represents the path of the found json data type JsPathStr = String; -pub(crate) fn jsp_idx(prefix: &str, idx: usize) -> String { +pub fn jsp_idx(prefix: &str, idx: usize) -> String { format!("{}[{}]", prefix, idx) } -pub(crate) fn jsp_obj(prefix: &str, key: &str) -> String { +pub fn jsp_obj(prefix: &str, key: &str) -> String { format!("{}.['{}']", prefix, key) } diff --git a/src/path/mod.rs b/src/path/mod.rs index f4322f0..b15b6ab 100644 --- a/src/path/mod.rs +++ b/src/path/mod.rs @@ -6,6 +6,7 @@ use serde_json::{json, Value}; use crate::parser::model::{Function, JsonPath, JsonPathIndex, Operand}; pub use crate::path::index::{ArrayIndex, ArraySlice, Current, FilterPath, UnionIndex}; +pub use crate::path::top::ObjectField; use crate::path::top::*; /// The module is in charge of processing [[JsonPathIndex]] elements @@ -111,7 +112,7 @@ impl JsonLike for Value { self.get(key) } - fn itre(&self, pref: String) -> Vec> { + fn itre(&self, pref: String) -> Vec> { let res = match self { Value::Array(elems) => { let mut res = vec![]; @@ -135,6 +136,7 @@ impl JsonLike for Value { res } } + fn array_len(&self) -> JsonPathValue<'static, Self> { match self { Value::Array(elems) => JsonPathValue::NewValue(json!(elems.len())), diff --git a/src/path/top.rs b/src/path/top.rs index 220fa79..8fe5e7a 100644 --- a/src/path/top.rs +++ b/src/path/top.rs @@ -150,7 +150,7 @@ impl FnPath { impl<'a, T> Path<'a> for FnPath where - T: JsonLike + 'static, + T: JsonLike, { type Data = T;