-
Notifications
You must be signed in to change notification settings - Fork 105
Support for Nullable
#174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Nullable
#174
Conversation
Added `_writejson` method for `Nullable` values. Maps to JSON `null` if value is null.
- `lower` JSON method to JSONify `DataFrame` - `readjson` method added to read JSONified `DataFrame`s Depends upon JuliaIO/JSON.jl#174
|
Alternatively, |
|
I think a string makes more sense for the default serialization of |
TotalVerb
left a comment
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.
I think this is a reasonable change. @kmsquire thoughts?
|
|
||
| # check Chars | ||
| @test json('a') == "\"a\"" | ||
| @test 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.
Can we test the following too?
- a non-ASCII character
- a control character (like
\t)
| @test sprint(JSON.print, [Inf]) == "[null]" | ||
|
|
||
| # check Nullables are printed correctly | ||
| @test sprint(JSON.print, [Nullable{Int64}()]) == "[null]" |
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.
Test Nullable() also
src/JSON.jl
Outdated
| end | ||
| end | ||
|
|
||
| function _writejson(io::IO, state::State, c::Char) |
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.
This can probably be made a lower method with no performance penalty (since the string has to be allocated anyway). JSON.lower(c::Char) = string(c). The Nullable one we can keep as-is, since lower would be type-unstable.
|
Thanks for the feedback :) |
|
Is there anything else you need from me on this one? |
|
@joshbode I was waiting on feedback from others, but I think this will be a pretty uncontroversial change. Will merge. Do you need it tagged? |
|
Thanks for that! Yes please :) |
|
Will do. Thank you for the contribution! |
|
My pleasure - hoping to introduce JSON read/write for |
Added
_writejsonmethod forNullablevalues. Maps to JSONnullifvalue is null.
(edit by TotalVerb: fixes #132)