add Removed enum type to discard removed fields on parsing stage

This commit is contained in:
Ihor Andrianov 2025-01-29 16:45:09 +02:00
parent f97d085934
commit 5c55615896
No known key found for this signature in database
2 changed files with 5 additions and 0 deletions

View file

@ -519,6 +519,9 @@ pub mod ordered_object {
use serde::ser::SerializeMap;
let mut map = serializer.serialize_map(Some(pairs.len()))?;
for (k, v) in pairs {
if let Val::Removed = v {
continue;
}
map.serialize_entry(k, v)?;
}
map.end()

View file

@ -24,6 +24,7 @@ pub enum Val {
Float(f64),
String(String),
Array(Vec<Val>),
Removed,
#[serde(with = "ordered_object")]
Object(Vec<(String, Val)>),
}
@ -313,6 +314,7 @@ pub fn json_type(value: &OwnedValue, path: Option<&OwnedValue>) -> crate::Result
Val::String(_) => "text",
Val::Array(_) => "array",
Val::Object(_) => "object",
Val::Removed => unreachable!(),
};
Ok(OwnedValue::Text(LimboText::json(Rc::new(val.to_string()))))