On 16 juil, 16:42, Alex <[email protected]> wrote:
> ermm,
> this is the situation,
> i have a txt file, it contains
>
> [
>                     {
>                         "cmdType":"G",
>                         "row":0,
>                         "col":2,
>                         "ans":"心",
>                         "cmd":"C",
>                         "qNum":19
>                     },
>                     {
>                         "cmdType":"G",
>                         "row":1,
>                         "col":1,
>                         "ans":"心",
>                         "cmd":"C"
>                     }
> ]
>
> i need to parse that and get one of the json object that inside that
> json array and send that json object as string to client. the code
> that i posted on the first post only works when there is no chinese
> character in it.
>
> this is the exception i get when it has chinese character in it.
> Exception in thread "main" com.google.gson.JsonParseException: Failed
> parsing JSON source: java.io.bufferedrea...@530daa to Json
>         at com.google.gson.JsonParser.parse(JsonParser.java:57)
>         at xwp.server.Test.main(Test.java:23)
> Caused by: com.google.gson.TokenMgrError: Lexical error at line 1,
> column 1.  Encountered: "\ufeff" (65279), after : ""

Which means that, either:
 - You're giving the BOM to GSON as the very first character, which is
a mistake (you should skip it if there's one in your file; this is
something that unfortunately Java won't do for you [1,2])
 - You have a zero-width no-break space in your JSON (but because the
error points line=1;column=1, I'd rather say it's the BOM)

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
[2] 
http://stackoverflow.com/questions/1835430/byte-order-mark-screws-up-file-reading-in-java
[3] http://www.fileformat.info/info/unicode/char/feff/index.htm

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to