加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

JSONKit :Illegal \u Unicode escape sequence

发布时间:2020-12-16 19:24:21 所属栏目:百科 来源:网络整理
导读:When JSON string contains unicodes between u0000 and u001f,JSONKit parser fails to work properly. and throws a error as “Illegal u Unicode escape sequence”. This is a known issue(link) but seems like the author thought it’s a fault caus

When JSON string contains unicodes between u0000 and u001f,JSONKit parser fails to work properly. and throws a error as “Illegal u Unicode escape sequence”.

This is a known issue(link) but seems like the author thought it’s a fault caused by content provider and didn’t intend to have any fix on this issue.

In this particular case,these services are very clearly “in the wrong”.RFC 4627is unambiguous that characters <0x20are verboten. In cases like there,where something is clearly violating the standard,my default response is that “It’s the other persons (web service) problem.” The standard is the standard,and it is Right(tm),even its mistakes.

But in fact there are many JSON encoder may generates JSON string contains invalid characters < 0×20 including Python2.6,<not tested in Python2.7>,pre-rails3. We all love the clean codes but we need make things done first.

SOLUTION:

Edit JSONKit.m file:

//GOTO Line 1462 or nearby
//      remove this line
//      if(JK_EXPECT_F(currentChar < 0x20UL)) { jk_error(parseState,@"Invalid character < 0x20 found in string: 0x%2.2x.",currentChar); stringState = JSONStringStateError; goto finishedParsing; }
//      add following codes
        if(JK_EXPECT_F(currentChar < 0x20UL) && (parseState->parSEOptionFlags & JKParSEOptionLooseUnicode) == 0) {
            jk_error(parseState,currentChar); stringState = JSONStringStateError; goto finishedParsing;
        }
        else {
            currentChar = 0xFFFDUL;
        }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读