日期:2014-05-17  浏览次数:20527 次

js转json,eval('(' + data + ')')之前和之后的数据不一致~~急
后台代码:

System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

str = serializer.Serialize(actionList);

context.Response.ContentType = "text/plain";

context.Response.Write(str);

 

前台代码:

$.post("../Ashx/UserActionHandler.ashx?Method=GetUserAction", obj, function (data) {

  alert(data);

  var jsonlist = eval('(' + data + ')'); //转换后的JSON对象

  for (var i = 0; i < jsonlist.length; i++) {

  alert(jsonlist[i].userId);

  }

  });

alert(data);得到的值为

[{"ExtensionData":{},"action":"今天遇到一个很麻烦的问题,现在还没有找到解决方案,真是头疼啊。。。。","actionType":1,"createTime":"2012-08-17 17:44","deleted":0,"id":5,"userId":3494080016379720743},{"ExtensionData":{},"action":"非常hapy啊~","actionType":1,"createTime":"2012-08-17 08:23","deleted":0,"id":4,"userId":3494080016379720743},{"ExtensionData":{},"action":"在北京xxxx公司第一天上班,感觉还不错吆,同事对我都可好了。都可好了。在北京xxxx公司第一天上班,感觉还不错吆,同事对我都可好了","actionType":1,"createTime":"2012-08-17 08:18","deleted":0,"id":3,"userId":3494080016379720743},{"ExtensionData":{},"action":"今天心情很好啊,哈哈哈中~~~","actionType":1,"createTime":"2012-08-17 08:15","deleted":0,"id":2,"userId":3494080016379720743}]
 
但是

alert(jsonlist[i].userId); 输出的是 3494080016379720700

不明白为什么userid后两位会变成00

有人知道是怎么回事吗?
 


------解决方案--------------------
"userId":"3494080016379720743"}将UERID变成字符串看看
------解决方案--------------------
明显精度不够了,用字符串吧