discomarathon / google-gson

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

JsonParseException is not very informative (does not return the offending string) #186

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. trigger a JsonParseException at the invocation of Gson.fromJson (by 
providing a malformed String)
2. catch and print the trace (e.printStackTrace())
3. the trace print does not provide the offending String

What is the expected output? What do you see instead?
Here is the expected output:
com.google.gson.JsonParseException: Failed parsing JSON source: "actual 
malformed Json string" to Json

and here is what I got instead:
com.google.gson.JsonParseException: Failed parsing JSON source: 
java.io.StringReader@a0dcd9 to Json

looking at the sources:
JsonParser.java:59 we find:
      throw new JsonParseException("Failed parsing JSON source: " + json + 
" to Json", e);
maybe (...??) the following could be used:

What version of the product are you using? On what operating system?
gson-1.4 on Windows XP

Please provide any additional information below.

Original issue reported on code.google.com by mperdik...@gmail.com on 20 Jan 2010 at 10:52

GoogleCodeExporter commented 9 years ago
Fixed by JsonReader.

Original comment by limpbizkit on 27 Aug 2010 at 7:41