discomarathon / google-gson

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

crash with embeded " #189

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
gson.fromJson("{\"title\":\"? The Trend: \"Can You Write News\" ? The
Search For Stuff:\"}", Object.class);

What is the expected output? What do you see instead?

Should parse (with an error because of using Object.class) instead throws:

Caused by: com.google.gson.ParseException: Encountered "
<IDENTIFIER_SANS_EXPONENT> "Can "" at line 1, column 25.
Was expecting one of:
    "}" ...
    "," ...

com.google.gson.JsonParseException: Failed parsing JSON source:
java.io.StringReader@380e28b9 to Json
        at com.google.gson.JsonParser.parse(JsonParser.java:59)
        at com.google.gson.Gson.fromJson(Gson.java:443)
        at com.google.gson.Gson.fromJson(Gson.java:396)
        at com.google.gson.Gson.fromJson(Gson.java:372)
        at Test.foo(Test.java:139)
        at
com.google.gson.JsonParserJavacc.generateParseException(JsonParserJavacc.java:70
5)
        at
com.google.gson.JsonParserJavacc.jj_consume_token(JsonParserJavacc.java:587)
        at
com.google.gson.JsonParserJavacc.JsonObject(JsonParserJavacc.java:82)
        at com.google.gson.JsonParserJavacc.parse(JsonParserJavacc.java:36)
        at com.google.gson.JsonParser.parse(JsonParser.java:54)

What version of the product are you using? On what operating system?

1.4 Windows 7 64-bit.

Please provide any additional information below.

The issue is the \"Can You Write News\" - works if you change it to \\\"Can
You Write News\\\".  From what I can tell it should work with out the
additional \\ though.

Original issue reported on code.google.com by dstobede...@gmail.com on 22 Jan 2010 at 11:13

GoogleCodeExporter commented 9 years ago
Fixed by JsonReader.

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