DonaldDu / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

dangling colon makes gson create a null reference #424

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hello everyone,

in my tests, json like this:

{"a":["x","y","z",]}

generates the "List<String>a" as expected, but the size is 4 and the last one 
is null.

this behavior was not observed at native javascript array length neither in 
libjson on C application.

Is this the correct behavior and C/Javascript implementations are incorrect?

It's easy to deal with, yet it was the single discrepacy detected between my 3 
apps consuming the very same json.

T.I.A.

Original issue reported on code.google.com by Sombr...@gmail.com on 24 Mar 2012 at 3:09

GoogleCodeExporter commented 9 years ago
The above is not valid JSON. If you want your parsers to all agree, you should 
use valid JSON.

We've chosen to insert omitted nulls because that's what early versions of the 
org.json parser did. That was probably the wrong decision. But we're mostly 
stuck with it for backwards compatibility.

Original comment by limpbizkit on 11 Apr 2012 at 8:41