Closed GoogleCodeExporter closed 9 years ago
Please simply ignore this line: Confusingly the no catch block is required by
Eclipse, although the method definition specifies a throw.
What is the expected output? What do you see instead?
In my understanding of the documentation the function should throw a
JsonSyntaxException. Instead we get an instance of JsonNull...
Original comment by luscus.r...@gmail.com
on 11 May 2012 at 2:58
Good find. That's definitely bad behavior on Gson's part.
Your best bet is to avoid JsonParser. Instead just do this:
new Gson().fromJson("[[]", JsonElement.class)
Inder, any recommendations on how we should proceed here? I suspect the current
behavior is for backwards compatibility with Gson 1.6.
Original comment by limpbizkit
on 30 Jun 2012 at 3:17
I think we should fix JsonParser to throw a JsonSyntax exception.
Original comment by inder123
on 30 Jun 2012 at 6:23
This issue was closed by revision r1156.
Original comment by inder123
on 30 Jun 2012 at 6:48
Fixed in r1156
However, it now throws JsonIOException instead of JsonParseException. It can be
argued that JsonSyntaxException would have been a better choice. However, since
the root cause is an IOException (EOFException), JsonIOException makes sense
too.
Somewhat inconsistently, the same done view gson.fromJson("[[]",
Object[].class) throws JsonSyntaxException.
IMHO, this incosistency is tolerable, though we can easily fix it by adding a
check in JsonParser. I would like to hear other opinions before making that
change though.
Original comment by inder123
on 30 Jun 2012 at 6:51
Changed the behavior to throw JsonSyntaxException in r1157
Original comment by in...@trymph.com
on 2 Jul 2012 at 6:37
Original issue reported on code.google.com by
luscus.r...@gmail.com
on 11 May 2012 at 2:39