-
Notifications
You must be signed in to change notification settings - Fork 223
Fixed encoding of NaN
to json
#990
Fixed encoding of NaN
to json
#990
Conversation
src/io/json/write/serialize.rs
Outdated
@@ -43,6 +43,46 @@ fn primitive_serializer<'a, T: NativeType + ToLexical>( | |||
)) | |||
} | |||
|
|||
fn f64_serializer<'a>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use generics to have a single implementation;
fn float_serializer<'a, T>(
array: &'a PrimitiveArray<T>,
) -> Box<dyn StreamingIterator<Item = [u8]> + 'a + Send + Sync>
where T: num_traits::Float + NativeType + lexical_core::ToLexical
{
Box::new(BufStreamingIterator::new(
array.iter(),
|x, buf| {
if let Some(x) = x {
if T::is_nan(*x) {
buf.extend(b"null")
} else {
lexical_to_bytes_mut(*x, buf)
}
} else {
buf.extend(b"null")
}
},
vec![],
))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, didn't know that was possible 🎉
Codecov Report
@@ Coverage Diff @@
## main #990 +/- ##
==========================================
+ Coverage 71.37% 71.39% +0.02%
==========================================
Files 357 357
Lines 19781 19791 +10
==========================================
+ Hits 14118 14130 +12
+ Misses 5663 5661 -2
Continue to review full report at Codecov.
|
float::NAN
to json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the PR. It looks great 💯
Thanks a lot @ritchie46 for the review 🙇
float::NAN
to jsonNaN
to json
fixes: #988