日期:2014-05-20  浏览次数:21229 次

SCRIPT1007: 缺少 ']' json数据格式没问题 二维
"{\"purgin\":[{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"李龙\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"},{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"李龙\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"},{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"华硕\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"}]}"
返回的json数据
eval() 的话可以过  但是就是不解析
eval('(' + msg + ')');
eval("(" + msg + ")");
都试过了一样
json

------解决方案--------------------

var str="{\"purgin\":[{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"李龙\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"},{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"李龙\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"},{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"华硕\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"}]}"
eval("v="+str)
console.log(v)

------解决方案--------------------
可以转化的。是不是你取值不对?

var msg = "{\"purgin\":[{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"李龙 \",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"},{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"李龙\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"},{\"SupercargoBatchNumber\":\"Y001\",\"SupercargoBatchClearState\":\"1\",\"SupercargoGroupTime\":\"1922/12/12 0:00:00\",\"SupercargoGroupName\":\"刀郎组\",\"Name\":\"华硕\",\"TransType\":\"现金交易\",\"Barcode\":\"0001\",\"Amount\":\"100.00\",\"Count\":\"1\",\"ClearState\":\"1\"}]}";
var jsn = eval('('+msg+')');
alert(jsn.purgin[0].SupercargoBatchNumber);