yunussasmaz / google-gson

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

com.google.gson.ParseException when Json string contains new line characters #236

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a Json string containing new line characters ie. \n or \r\n
e.g.
{"rid":"3fe769c3-93ee-43b4-91ee-2f279cf5e9bb","org":"001","acno":"TL000000000068
","fseq":"7893ca16-ed66-431a-96fd-c20001efa487","actcd":"IA","fdt":"17.09.2010",
"rescd":"PTP","nactcd":"IA","nactdt":"17.09.2010","note":"Remarks\r\nRemarks","f
ee":"N","toall":"N","watch":"N","promises":[{"prdt":"17.09.2010","pramt":"100.00
0"}]} 
2.Parse string using JsonStreamParser

What is the expected output? What do you see instead?
The string should be parsed but it throws following exception:
Exception in thread "main" com.google.gson.JsonParseException: Failed parsing 
JSON source to Json
    at com.google.gson.JsonStreamParser.next(JsonStreamParser.java:91)
    at com.rsystems.services.util.JSONUtil.getMapFromJson(JSONUtil.java:49)
    at com.rsystems.services.testing.TestUtil.main(TestUtil.java:35)
Caused by: com.google.gson.ParseException: Encountered " "\"" "\" "" at line 1, 
column 218.
Was expecting one of:
    <DIGITS> ...
    "null" ...
    "NaN" ...
    "Infinity" ...
    <BOOLEAN> ...
    <SINGLE_QUOTE_LITERAL> ...
    <DOUBLE_QUOTE_LITERAL> ...
    "{" ...
    "[" ...
    "-" ...

    at com.google.gson.JsonParserJavacc.generateParseException(JsonParserJavacc.java:705)
    at com.google.gson.JsonParserJavacc.jj_consume_token(JsonParserJavacc.java:587)
    at com.google.gson.JsonParserJavacc.JsonValue(JsonParserJavacc.java:229)
    at com.google.gson.JsonParserJavacc.Pair(JsonParserJavacc.java:112)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:95)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.Members(JsonParserJavacc.java:99)
    at com.google.gson.JsonParserJavacc.JsonObject(JsonParserJavacc.java:76)
    at com.google.gson.JsonParserJavacc.parse(JsonParserJavacc.java:36)
    at com.google.gson.JsonStreamParser.next(JsonStreamParser.java:87)
    ... 2 more

What version of the product are you using? On what operating system?
com.google.code.gson version 1.4

Please provide any additional information below.

Original issue reported on code.google.com by bhavesh....@gmail.com on 17 Sep 2010 at 7:35

GoogleCodeExporter commented 9 years ago
Same exception occurs even for version 1.5

Original comment by bhavesh....@gmail.com on 17 Sep 2010 at 7:38

GoogleCodeExporter commented 9 years ago
Can you try the latest code from SVN? I believe it's fixed there.

Original comment by limpbizkit on 17 Sep 2010 at 2:57

GoogleCodeExporter commented 9 years ago
It works with the latest code from SVN. Thanks :)
When will this be included in the release on maven repo?

Original comment by bhavesh....@gmail.com on 17 Sep 2010 at 3:46

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 3 Oct 2010 at 6:38

GoogleCodeExporter commented 9 years ago
Could you please let us know When will this be included in the release ?

Original comment by iit.ni...@gmail.com on 20 Oct 2010 at 9:57