1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! JMESPath Community is [the community implementation](https://jmespath.site/) of JMESPath,
//! a query and transformation language for JSON.
//!
//! # Evaluating JMESPath Expression
//!
//! Use the [search](crate::search) function to evaluate a JMESPath expression.
//!
//! ## Example
//! ```rust
//! use jmespath_community as jmespath;
//! use jmespath::{search, Value};
//!
//!// Parse some JSON data into a JMESPath variable
//!let json_str = "{\"foo\":{\"bar\":{\"baz\":true}}}";
//!let data = Value::from_json(json_str).unwrap();
//!
//!let result = search("foo.bar | baz", &data).unwrap();
//!assert_eq!(true, result);
//! ```
//!
//! A JMESPath expression can be parsed once and evaluated
//! multiple times using the [parse](crate::parser::parse) function.
//!
//! ## Example
//! ```rust
//! use jmespath_community as jmespath;
//! use jmespath::{parse, Value};
//!
//! let ast = parse("foo").unwrap();
//! let data = Value::from_json(r#"{"foo": "bar"}"#).unwrap();
//! let result = ast.search(&data).unwrap();
//! assert_eq!("bar", result);
//! ```
//!
//! # Registering Custom Functions
//!
//! JMESPath Community comes with a host of useful [builtin functions](https://jmespath.site/main/#functions).
//! However, it can be extended with [third-party functions](crate::function).
//!
//! ## Example
//! ```rust
//! mod custom_functions {
//!
//! use jmespath_community as jmespath;
//!
//! use jmespath::function;
//!
//! use jmespath::errors::Error as RuntimeError;
//!
//! use jmespath::FunctionContext;
//! use jmespath::Value;
//!
//! use jmespath::functions::ReturnValue;
//! use jmespath::functions::Function;
//!
//! use jmespath::functions::DataType;
//! use jmespath::functions::ParamTypes::*;
//! use jmespath::functions::Parameter;
//! use jmespath::functions::Parameter::*;
//!
//! function!(
//! add,
//! [
//! left => Required(Of(DataType::Number)),
//! right => Required(Of(DataType::Number))
//! ],
//! arguments,
//! {
//! // type checking has been performed by the runtime
//! // safe to unwrap
//!
//! let i = arguments[0].as_f64().unwrap();
//! let j = arguments[1].as_f64().unwrap();
//!
//! Value::from_f64(i + j)
//! }
//! );
//! }
//! ```
//!
//! Create a new instance of the JMESPath [Runtime](crate::Runtime) object and
//! register your custom function:
//!
//! ## Example
//! ```compile_fail
//! use jmespath_community as jmespath;
//! use jmespath::FunctionRegistrar;
//! use jmespath::{Runtime, Value};
//!
//! let add = Box::new(custom_functions::add::new());
//! let mut runtime = Runtime::create_runtime();
//! runtime.register(add);
//!
//! let expression = "foo";
//! let root = Value::Null;
//! let result = runtime.search(expression, &root).unwrap();
//!
//! assert_eq!(None, result);
//! ```
/// Contains the types supporting error handling for this crate.
/// Defines the builtin JMESPath function implementations and
/// various helpers for authoring custom third-party functions.
/// Contains the main JMESPath expression interpreter.
pub
pub
pub
pub
pub
pub
/// A type that represents a JMESPath function that can be stored
/// into a thread-safe registry.
pub type JmesPathFunction = dyn crate Function + Send + Sync;
pub use *;
pub use Map;
pub use Number;
pub use Error;
pub use parse;
pub use NodeType;
pub use Slice;
pub use AST;
pub use ByFunctionHolder;
pub use FunctionContext;
pub use FunctionRegistrar;
pub use Runtime;
pub use Value;