Skip to content

Commit

Permalink
Ommit None values in sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiburt committed Nov 6, 2021
1 parent 0462456 commit 67ab23d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ impl<'p, 'a> Serialize for SerializePyObject<'p, 'a> {
cast!(|x: $type| {
let mut seq = serializer.serialize_seq(Some(x.len()))?;
for element in x {
if element.is_none() {
// None values must be omitted
continue
}

seq.serialize_element(&SerializePyObject {
py: self.py,
obj: element,
Expand Down

0 comments on commit 67ab23d

Please sign in to comment.