discomarathon / google-gson

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

Gson fails to parse strings with chinese characters #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Gson fails to parse: 

{"name": "好", "code": "aa", "remark": "aa"}

gson.fromJson(jsonString, TbDepartment.class);

的时候出现异常 Failed parsing JSON source: {"name": "好", "code": "aa",
"remark": "aa"} to Json 

See:
http://groups.google.com/group/google-gson/browse_thread/thread/588a87b9ef1fc479

Original issue reported on code.google.com by inder123 on 29 Jul 2008 at 12:28

GoogleCodeExporter commented 9 years ago
Added a test to reproduce this bug in r131. Seems like our parser does not 
handle
unicode strings properly.

Original comment by inder123 on 5 Aug 2008 at 10:14

GoogleCodeExporter commented 9 years ago
r134 has some additional tests some of which pass. One thing to note is that 
Gson
will serialize a string with chinese characters correctly, by converting them to
escaped unicode. It would probably be better to convert these to unescaped 
unicode,
but at least it is valid Json.

Original comment by inder123 on 7 Aug 2008 at 11:54

GoogleCodeExporter commented 9 years ago
Fixed in r138 by enabling hte parser to treat all input as unicode strings. This
works because we are feeding java strings to the parser, and java strings are 
always
unicode.

Original comment by inder123 on 8 Aug 2008 at 2:04

GoogleCodeExporter commented 9 years ago
Issue 80 has been merged into this issue.

Original comment by joel.leitch@gmail.com on 12 Dec 2008 at 9:38