Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

不能正确处理一些Unicode字符 #304

Closed
hengyunabc opened this issue Mar 10, 2015 · 2 comments
Closed

不能正确处理一些Unicode字符 #304

hengyunabc opened this issue Mar 10, 2015 · 2 comments
Milestone

Comments

@hengyunabc
Copy link
Contributor

测试代码:

        JSONObject o = new JSONObject();
        o.put("test", "Intki_E96?� Build");
        System.err.println(o.toJSONString());
        Object object = JSON.parse(o.toJSONString());
        System.err.println(object);

异常:

Exception in thread "main" com.alibaba.fastjson.JSONException: unclosed single-quote string
    at com.alibaba.fastjson.parser.JSONLexerBase.scanStringSingleQuote(JSONLexerBase.java:2677)
    at com.alibaba.fastjson.parser.JSONLexerBase.nextToken(JSONLexerBase.java:144)
    at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:470)
    at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1236)
    at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1205)
    at com.alibaba.fastjson.JSON.parse(JSON.java:108)
    at com.alibaba.fastjson.JSON.parse(JSON.java:99)
@hengyunabc
Copy link
Contributor Author

那个字符串粘到github上被干掉了。。貌似最新版修复了这个问题。1.1.35有问题。
但是最新版处理这个还是有问题:

        String ss = "{'a':'Intki_E96?\u001A Build'}";
        System.err.println(ss);
        Object sss = JSON.parse(ss);

这个\u001A 貌似是个合法的Unicode字符,历史遗留物。

http://stackoverflow.com/questions/17024436/what-is-the-unicode-u001a-character-aka-0x1a

@DreamSea530
Copy link

JSONObject j=new JSONObject();
j.put("a","\t");
System.out.println(j.toJSONString());

转义字符\t也没做处理

@wenshao
Copy link
Member

wenshao commented Apr 13, 2016

bug fixed. included in 1.2.9 & 1.1.49.android.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants