String a = "{"id": 168986793\n" +
" ,"name": "护舒宝瞬洁贴身量多日用\夜用卫生巾5+1片284mm"\n" +
" ,"price": "10"\n" +
" ,"origin_price": "10"\n" +
" ,"minCount": "1"\n" +
" ,"onSale": "1"\n" +
" ,"sku": [ {"id": 181562658\n" +
" ,"name": ""\n" +
" ,"price": "10"\n" +
" ,"origin_price": "10"\n" +
" ,"minCount": 1\n" +
" ,"stock": 0\n" +
" ,"isSellOut": 0\n" +
" }\n" +
" ]\n" +
" }";
Exception in thread "main" com.alibaba.fastjson.JSONException: unclosed string : 夜
at com.alibaba.fastjson.parser.JSONLexerBase.scanString(JSONLexerBase.java:975)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:441)
at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1327)
at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1293)
at com.alibaba.fastjson.JSON.parse(JSON.java:137)
at com.alibaba.fastjson.JSON.parse(JSON.java:128)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:201)
用的1.2.24
3条答案
按热度按时间fcg9iug31#
JSONLexerBase
scanString()方法这样改下,貌似就好了
default:
this.ch = ch;
putChar('');
putChar(ch);
//throw new JSONException("unclosed string : " + ch);
aor9mmx12#
json格式不对,如果你是在代码字符串里面写,应该是
\\\\,
转义.如
String test1 = "{\"id\": 168986793, \"name\": \"护舒宝瞬洁贴身量多日用\\\\,夜用卫生巾5+1片284mm\"}";
文件中测试ok.
test.json
balp4ylt3#
是单斜杠报错