出现错误,Unexpected end of JSON input
Closed this issue · 6 comments
msxfXF commented
msxfXF commented
maxchang3 commented
msxfXF commented
maxchang3 commented
hexo: 6.2.0 hexo-cli: 4.3.0 os: win32 10.0.19043
啊,是这样的。但是同样的内容下有的解析就是正确的,有的却会出现你上述的情况。我还没找到具体的原因。不过这也算是一个解决方法 :) 之前我也试过转义但是好像出了些问题……所以这样修改后,解析是正常的吗? 可以的话我把他加到代码里。
htmlEncodeByRegExp 的实现是如下吗? 后面还需要 decode 吗?
function htmlEncodeByRegExp (str){
var s = "";
if(str.length == 0) return "";
s = str.replace(/&/g,"&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/ /g, " ");
s = s.replace(/\'/g, "'");
s = s.replace(/\"/g, '"');
return s;
}
msxfXF commented
function htmlEncodeByRegExp (str){
var s = "";
if(str.length == 0) return "";
s = str.replace(/&/g,"&");
s = s.replace(/</g,"<");
s = s.replace(/>/g,">");
s = s.replace(/ /g," ");
s = s.replace(/\'/g,"'");
s = s.replace(/\"/g,""");
return s;
}
这样修改以后可以正常显示了,后续不需要decode
maxchang3 commented
function htmlEncodeByRegExp (str){ var s = ""; if(str.length == 0) return ""; s = str.replace(/&/g,"&"); s = s.replace(/</g,"<"); s = s.replace(/>/g,">"); s = s.replace(/ /g," "); s = s.replace(/\'/g,"'"); s = s.replace(/\"/g,"""); return s; }这样修改以后可以正常显示了,后续不需要decode
好的,感谢,我会尽快处理!~