On 2013-01-15, at 2:42 PM, Jitendra Kotamraju wrote:
It appears this is coming in JDK8 (it's called Optional<T>), and that's all the more reason we shouldn't introduce our own in this API.
I see the discussion was divided. Certainly Doug Lea and Brian Goetz came out against the use of nulls in collections. But it seems that by the end of the thread, a patch was put forward that makes the new default methods on Map null-friendly. I don't think it will really matter that null mappings get skipped in streaming operations. I think it's only in special cases where we care to know the difference between null and missing.
But getting back to the question of which is more confusing, here are some examples of the type of confusion I'm talking about. These are all from the first page of Google results for "java json null value":
That's right: 5 of the top 10 results for "java json null value" are about confusion over this very issue with other JSON APIs that use a special JsonNull type rather than Java null.
As it turns out, there is at least one Java JSON library that implements the idea I'm proposing. The JSON.simple library (I just found it today; was previously unaware of it) uses Java null for JSON null: https://code.google.com/p/json-simple/#Mapping_Between_JSON_and_Java_Entities
If you scroll down that page a bit to "JSON.simple in Projects/Products," it looks like JSON.simple has pretty good adoption in a number of high-profile projects. I think this demonstrates that the suggestion of eschewing JsonValue.NULL isn't completely insane. :)
[jsr353-experts] Re: [json-processing-spec users] Re: Re: Re: Re: Re: Json Null type: friend or foe?