File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use crate :: db:: DB ;
2- use jsonpath_rust:: JsonPath ;
2+ use jsonpath_rust:: query :: js_path_vals ;
33use serde_json:: Value ;
44use std:: cmp:: Ordering ;
5- use std:: str:: FromStr ;
65
76use tracing:: { Level , span} ;
87
@@ -218,18 +217,13 @@ fn evaluate_expression(expr: &Expression, doc: &Value) -> Value {
218217 match expr {
219218 Expression :: FieldReference ( path) => get_path ( doc, path) . unwrap_or ( Value :: Null ) ,
220219 Expression :: JsonPath ( path) => {
221- if let Ok ( p) = JsonPath :: from_str ( path) {
222- let inst = p. find ( doc) ;
223- if let Some ( arr) = inst. as_array ( ) {
224- if arr. is_empty ( ) {
225- Value :: Null
226- } else if arr. len ( ) == 1 {
227- arr[ 0 ] . clone ( )
228- } else {
229- inst. clone ( )
230- }
220+ if let Ok ( nodes) = js_path_vals ( path, doc) {
221+ if nodes. is_empty ( ) {
222+ Value :: Null
223+ } else if nodes. len ( ) == 1 {
224+ nodes[ 0 ] . clone ( )
231225 } else {
232- inst
226+ Value :: Array ( nodes . into_iter ( ) . cloned ( ) . collect ( ) )
233227 }
234228 } else {
235229 Value :: Null
You can’t perform that action at this time.
0 commit comments