Skip to content

Commit

Permalink
Merge pull request #2 from isar/bug/1533
Browse files Browse the repository at this point in the history
fix(native): importJson nullable static properties
  • Loading branch information
mrclauss authored Feb 23, 2024
2 parents 7e756f7 + c3ece15 commit cc66209
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/isar_core/src/core/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ macro_rules! write_scalar {
let value = $map.next_value::<Option<$type>>()?;
if let Some(value) = value {
$writer.$write($index as u32, value);
} else {
$writer.write_null($index as u32);
}
}};
}
Expand All @@ -147,13 +149,18 @@ impl<'a, 'de: 'a, W: IsarWriter<'a>, F: Fn(&str) -> i64> Visitor<'de>
A: MapAccess<'de>,
{
let mut id = None;

let mut visited_property_indexes = Vec::new();

while let Some(key) = map.next_key::<Cow<'_, str>>()? {
let prop = self
.writer
.properties()
.enumerate()
.find(|(_, (n, _))| n == &key);
if let Some((mut index, (_, data_type))) = prop {
visited_property_indexes.push(index);

index += 1; // Skip id

match data_type {
Expand Down Expand Up @@ -247,6 +254,15 @@ impl<'a, 'de: 'a, W: IsarWriter<'a>, F: Fn(&str) -> i64> Visitor<'de>
map.next_value::<IgnoredAny>()?;
}
}

for property_index in 0..self.writer.properties().count() {
if visited_property_indexes.contains(&property_index) {
continue;
}

self.writer.write_null((property_index + 1) as u32);
}

Ok((id, self.writer))
}
}

0 comments on commit cc66209

Please sign in to comment.