Open GoogleCodeExporter opened 9 years ago
Just found another case: missing boolean values (.getBoolean("does not exist"))
return as false for Java but throw an exception in Html.
Original comment by pdr@google.com
on 1 Jul 2011 at 1:44
I just wrote some code that heavily depends on the assumption that
.getBoolean() returns false, .getNumber() returns 0 etc. (Don't worry, it's not
committed.)
It makes lots of things simpler if there are default values for the calls, but
it also causes some issues. So currently there is no easy way to check if the
boolean key is missing or if it's just false. Yes, you could get the key array
and iterate through that, but that's far from optimal.
Related problem is the situation where you call .getBoolean() on a key that's
actually a number. Does anyone have any idea how that works in different
implementations?
If I may suggest a solution, something like .getKeyType() which would return
the type or something like Json.UNDEFINED if the key doesn't exist.
But it sounds like getting the defaults working should be a lot less work and
it's more urgent anyway.
Original comment by aki.jan...@rovio.com
on 1 Jul 2011 at 10:46
Just a random tip for checking that your JSON is valid: You can paste it into
http://jsonlint.com. JsonLint will flag some of these issues (trailing commas).
Original comment by pdr@google.com
on 5 Jul 2011 at 8:02
Original issue reported on code.google.com by
jgw@google.com
on 13 May 2011 at 2:36