jklin
jklin
  • 发布:2014-08-18 10:17
  • 更新:2014-09-18 17:07
  • 阅读:3287

json传回的内容里如果带有单个号,会自动变为双引号

分类:HTML5+

用的是plus.net.XMLHttpRequest()请求服务器端
服务器端传回一个json格式的字符串,如果内容里包含单个号。那么在移动App端用alert显示的话,会自动变成双引号,同时解析出错。
示例里标题:任职'通知
到App端显示的时候,单引号自动变为双引号,同时解析出错

2014-08-18 10:17 负责人:无 分享
已邀请:
学习

学习

http://ask.dcloud.net.cn/question/109

DCloud_App_Array

DCloud_App_Array

确认是值中的单引号(')吗?
在最新的版本上验证没有发现这个问题,请更新到最新版本,下面是我们验证的脚本:
var xhr=new plus.net.XMLHttpRequest();
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200){
alert("Response Type: "+typeof(xhr.response));
alert("Response: "+JSON.stringify(xhr.response));
}else{
alert("failed!");
}
}
}
xhr.responseType="json";
xhr.open("GET","http://demo.dcloud.net.cn/test/xhr/json.php");
xhr.send();

该问题目前已经被锁定, 无法添加新回复