-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Figure out how to output/convert null
values with TOML backend
#253
Comments
cc @yawkat |
I can see the issue with conversions. A write feature for this sounds sensible. With a default empty string, how does this interact with deserialization? It would yield an empty string JsonToken after all. That is incompatible with most fields that could contain null, but there isn't really a better default value for this either. For this "symmetry" reason, it seems more reasonable to make it fail by default. Better fail in serialization and notice early than fail in deserialization. |
I don't think presented an empty String is bad form partly because this is how XML already works (although with newer optional support for But with 2.12
and thus empty String (and blank too to account for common pretty-printing) is accepted as Similarly, Properties backend defines
although I am not sure if it defines similar default coercions as XML (it probably should). So this is not really a new problem per se: lack of null presentation in formats (and some languages like... Perl I think?) has been encountered before. I just happened to bump into this with conversions that Does this make sense? |
Yea, if the other modules do it this way, it makes sense to adopt the behavior by default as well. I will work on implementing this then. |
oh btw @cowtowncoder , can you give me permission to set issue labels and such here? |
@yawkat did you accept membership in team? If that does not have enough access I can add more; will try to figure this out. |
Yep works now :) |
Ok good. Yes, "Write" access should be able to manage labels too. |
Looking at #256:
|
Yes, agreed that blank is less relevant for TOML specifically (one could argue against that for Properties too since I think parser trims leading space, and without any non-space there is no trailing). So that's fine.
And yes, "empty" would be For TOML, which has bit more typing than XML or Properties, (I was contemplating on empty-vs-null wrt Properties as well... it's bit tricky). |
Looks like
TOMGenerator.writeNull()
method throws an exception, since TOML does not support actual null values.While this sort of makes sense, I immediately noticed that this is problematic for conversions: for example when doing conversion in
jackson-benchmarks
for test data.One obvious solution would be, I think, to make this method just write empty String value, although other options exist, for example:
TomlWriteFeature
?) for something likeFAIL_ON_NULL_WRITE
(enabled or disabled by default?) that would let user select between fail, or output of default value (empty String).My initial suggestion would be to add a feature to allow failing, but have default be "write Empty String value instead of
null
".The text was updated successfully, but these errors were encountered: