diff --git a/crates/rustern-core/src/pipeline/level_classify.rs b/crates/rustern-core/src/pipeline/level_classify.rs index 71d7e36..8dcd640 100644 --- a/crates/rustern-core/src/pipeline/level_classify.rs +++ b/crates/rustern-core/src/pipeline/level_classify.rs @@ -32,6 +32,9 @@ pub fn level_classify( where S: Stream> + Send + 'static, { + let serde_level_pointer = level_key + .as_ref() + .map(|key| crate::source::parsed_json::json_pointer_from_dot_path(key)); inner.map(move |r| { r.map(|mut ev| { let Some(ref key) = level_key else { @@ -40,7 +43,9 @@ where let Some(ref parsed) = ev.structured else { return ev; }; - if let Some(lv) = parsed.level_str_at_dot_path(key) { + if let Some(lv) = + parsed.level_str_at_dot_path_with_serde_pointer(key, serde_level_pointer.as_deref()) + { ev.level = Some(classify_str(lv)); } ev diff --git a/crates/rustern-core/src/source/parsed_json.rs b/crates/rustern-core/src/source/parsed_json.rs index 4bb0c89..ba69b11 100644 --- a/crates/rustern-core/src/source/parsed_json.rs +++ b/crates/rustern-core/src/source/parsed_json.rs @@ -14,10 +14,22 @@ pub(crate) struct JaqConvertError; impl ParsedJson { pub fn level_str_at_dot_path(&self, dot_path: &str) -> Option<&str> { + self.level_str_at_dot_path_with_serde_pointer(dot_path, None) + } + + pub(crate) fn level_str_at_dot_path_with_serde_pointer( + &self, + dot_path: &str, + serde_pointer: Option<&str>, + ) -> Option<&str> { match self { Self::Serde(v) => { - let ptr = dot_pointer(dot_path); - v.pointer(&ptr).and_then(|x| x.as_str()) + if let Some(ptr) = serde_pointer { + v.pointer(ptr).and_then(|x| x.as_str()) + } else { + let ptr = json_pointer_from_dot_path(dot_path); + v.pointer(&ptr).and_then(|x| x.as_str()) + } } Self::Jaq(v) => val_dot_path(v, dot_path).and_then(val_as_str), } @@ -38,7 +50,7 @@ impl ParsedJson { } } -fn dot_pointer(path: &str) -> String { +pub(crate) fn json_pointer_from_dot_path(path: &str) -> String { if path.is_empty() { return String::new(); }