Skip to content

Commit 5c41200

Browse files
authored
chore: expose some symbol to help user use JsonLike trait (#76)
1 parent 10f21aa commit 5c41200

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
//! [`there`]: https://goessner.net/articles/JsonPath/
100100
101101
pub use parser::model::JsonPath;
102-
use parser::JsonPathParserError;
102+
pub use parser::JsonPathParserError;
103103
use serde_json::Value;
104104
use std::fmt::Debug;
105105
use std::ops::Deref;
@@ -263,10 +263,10 @@ macro_rules! jp_v {
263263
/// Represents the path of the found json data
264264
type JsPathStr = String;
265265

266-
pub(crate) fn jsp_idx(prefix: &str, idx: usize) -> String {
266+
pub fn jsp_idx(prefix: &str, idx: usize) -> String {
267267
format!("{}[{}]", prefix, idx)
268268
}
269-
pub(crate) fn jsp_obj(prefix: &str, key: &str) -> String {
269+
pub fn jsp_obj(prefix: &str, key: &str) -> String {
270270
format!("{}.['{}']", prefix, key)
271271
}
272272

src/path/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use serde_json::{json, Value};
66

77
use crate::parser::model::{Function, JsonPath, JsonPathIndex, Operand};
88
pub use crate::path::index::{ArrayIndex, ArraySlice, Current, FilterPath, UnionIndex};
9+
pub use crate::path::top::ObjectField;
910
use crate::path::top::*;
1011

1112
/// The module is in charge of processing [[JsonPathIndex]] elements
@@ -111,7 +112,7 @@ impl JsonLike for Value {
111112
self.get(key)
112113
}
113114

114-
fn itre(&self, pref: String) -> Vec<JsonPathValue<'_, Self>> {
115+
fn itre(&self, pref: String) -> Vec<JsonPathValue<Self>> {
115116
let res = match self {
116117
Value::Array(elems) => {
117118
let mut res = vec![];
@@ -135,6 +136,7 @@ impl JsonLike for Value {
135136
res
136137
}
137138
}
139+
138140
fn array_len(&self) -> JsonPathValue<'static, Self> {
139141
match self {
140142
Value::Array(elems) => JsonPathValue::NewValue(json!(elems.len())),

src/path/top.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<T> FnPath<T> {
150150

151151
impl<'a, T> Path<'a> for FnPath<T>
152152
where
153-
T: JsonLike + 'static,
153+
T: JsonLike,
154154
{
155155
type Data = T;
156156

0 commit comments

Comments
 (0)