mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-25 09:22:19 +00:00
remove unneeded module prefix
This commit is contained in:
parent
b49d95d5db
commit
5cff83ebbb
16
src/lib.rs
16
src/lib.rs
@ -211,11 +211,11 @@ pub use select::Selector;
|
|||||||
/// assert_eq!(json, ret);
|
/// assert_eq!(json, ret);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn compile<'a>(path: &'a str) -> impl FnMut(&Value) -> result::Result<Value, String> + 'a {
|
pub fn compile<'a>(path: &'a str) -> impl FnMut(&Value) -> result::Result<Value, String> + 'a {
|
||||||
let mut selector = select::Selector::new();
|
let mut selector = Selector::new();
|
||||||
let _ = selector.path(path);
|
let _ = selector.path(path);
|
||||||
let mut selector = Box::new(selector);
|
let mut selector = Box::new(selector);
|
||||||
move |json| {
|
move |json| {
|
||||||
let s: &mut select::Selector = selector.borrow_mut();
|
let s: &mut Selector = selector.borrow_mut();
|
||||||
let _ = s.value(&json);
|
let _ = s.value(&json);
|
||||||
s.select_to_value()
|
s.select_to_value()
|
||||||
}
|
}
|
||||||
@ -256,11 +256,11 @@ pub fn compile<'a>(path: &'a str) -> impl FnMut(&Value) -> result::Result<Value,
|
|||||||
/// assert_eq!(json, ret);
|
/// assert_eq!(json, ret);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn selector<'a>(json: &Value) -> impl FnMut(&'a str) -> result::Result<Value, String> {
|
pub fn selector<'a>(json: &Value) -> impl FnMut(&'a str) -> result::Result<Value, String> {
|
||||||
let mut selector = select::Selector::new();
|
let mut selector = Selector::new();
|
||||||
let _ = selector.value(json.into());
|
let _ = selector.value(json.into());
|
||||||
let mut selector = Box::new(selector);
|
let mut selector = Box::new(selector);
|
||||||
move |path: &'a str| {
|
move |path: &'a str| {
|
||||||
let s: &mut select::Selector = selector.borrow_mut();
|
let s: &mut Selector = selector.borrow_mut();
|
||||||
s.path(path)?.select_to_value()
|
s.path(path)?.select_to_value()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ pub fn selector<'a>(json: &Value) -> impl FnMut(&'a str) -> result::Result<Value
|
|||||||
/// assert_eq!(json, ret);
|
/// assert_eq!(json, ret);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn selector_as<T: serde::de::DeserializeOwned>(json: &Value) -> impl FnMut(&str) -> result::Result<T, String> {
|
pub fn selector_as<T: serde::de::DeserializeOwned>(json: &Value) -> impl FnMut(&str) -> result::Result<T, String> {
|
||||||
let mut selector = select::Selector::new();
|
let mut selector = Selector::new();
|
||||||
let _ = selector.value(json.into());
|
let _ = selector.value(json.into());
|
||||||
move |path: &str| {
|
move |path: &str| {
|
||||||
selector.path(path)?.select_to()
|
selector.path(path)?.select_to()
|
||||||
@ -348,7 +348,7 @@ pub fn reader<'a>(json: &Value) -> impl FnMut(&'a str) -> result::Result<Value,
|
|||||||
/// assert_eq!(json, ret);
|
/// assert_eq!(json, ret);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn select(json: &Value, path: &str) -> result::Result<Value, String> {
|
pub fn select(json: &Value, path: &str) -> result::Result<Value, String> {
|
||||||
let mut selector = select::Selector::new();
|
let mut selector = Selector::new();
|
||||||
selector.path(path)?.value(json.into())?.select_to_value()
|
selector.path(path)?.value(json.into())?.select_to_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ pub fn select_str(json: &str, path: &str) -> result::Result<String, String> {
|
|||||||
/// assert_eq!(ret, r#"[{"name":"친구3","age":30},{"name":"친구1","age":20}]"#);
|
/// assert_eq!(ret, r#"[{"name":"친구3","age":30},{"name":"친구1","age":20}]"#);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn select_as_str(json: &str, path: &str) -> result::Result<String, String> {
|
pub fn select_as_str(json: &str, path: &str) -> result::Result<String, String> {
|
||||||
select::Selector::new()
|
Selector::new()
|
||||||
.path(path)?
|
.path(path)?
|
||||||
.value_from_str(json)?
|
.value_from_str(json)?
|
||||||
.select_to_str()
|
.select_to_str()
|
||||||
@ -431,7 +431,7 @@ pub fn select_as_str(json: &str, path: &str) -> result::Result<String, String> {
|
|||||||
/// assert_eq!(person, ret);
|
/// assert_eq!(person, ret);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn select_as<T: serde::de::DeserializeOwned>(json: &str, path: &str) -> result::Result<T, String> {
|
pub fn select_as<T: serde::de::DeserializeOwned>(json: &str, path: &str) -> result::Result<T, String> {
|
||||||
select::Selector::new()
|
Selector::new()
|
||||||
.path(path)?
|
.path(path)?
|
||||||
.value_from_str(json)?
|
.value_from_str(json)?
|
||||||
.select_to()
|
.select_to()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user