$.parseJSON()报 对象不支持此属性或方法


[{"eqsn":"开卷线","Hour":"07:10:00","datetime":"2013-09-23","eqid":"2013092317151240038233190"},{"eqsn":"开卷线","Hour":"07:10:00","datetime":"2013-09-16","eqid":"2013092317200317045171826"},{"eqsn":"开卷线","Hour":"07:10:00","datetime":"2013-09-15","eqid":"2013092317203377322080592"},{"eqsn":"开卷线","Hour":"00:50:00","datetime":"2013-09-17","eqid":"2013092317332622322664873"},{"eqsn":"开卷线","Hour":"06:00:00","datetime":"2013-09-18","eqid":"2013092317351996072634767"}]


这个我循环拼出来的字符串,各位客官帮我看看哪里错了 ,为什么会报这种奇怪的错误!

5 个解决方案

#1


var obj = $.parseJSON('{"name":"John"}');
alert( obj.name === "John" );

#2


  var xx = '[{ "eqsn": "开卷线", "Hour": "07:10:00", "datetime": "2013-09-23", "eqid": "2013092317151240038233190" }, { "eqsn": "开卷线", "Hour": "07:10:00", "datetime": "2013-09-16", "eqid": "2013092317200317045171826" }, { "eqsn": "开卷线", "Hour": "07:10:00", "datetime": "2013-09-15", "eqid": "2013092317203377322080592" }, { "eqsn": "开卷线", "Hour": "00:50:00", "datetime": "2013-09-17", "eqid": "2013092317332622322664873" }, { "eqsn": "开卷线", "Hour": "06:00:00", "datetime": "2013-09-18", "eqid": "2013092317351996072634767"}]';

            var ChangeJson = $.parseJSON(xx);

#3


有引用jquery?
或者
function StrToJson(str) {
        var json = (new Function("return " + str))();
        return json;
}
用这个转试试 我经常用  

#4


引用jquery

   var strJson = '{"XXOOSS": [{"eqsn":"开卷线","Hour":"07:10:00","datetime":"2013-09-23","eqid":"2013092317151240038233190"},{"eqsn":"开卷线2","Hour":"07:10:00","datetime":"2013-09-16","eqid":"2013092317200317045171826"},{"eqsn":"开卷线","Hour":"07:10:00","datetime":"2013-09-15","eqid":"2013092317203377322080592"},{"eqsn":"开卷线","Hour":"00:50:00","datetime":"2013-09-17","eqid":"2013092317332622322664873"},{"eqsn":"开卷线","Hour":"06:00:00","datetime":"2013-09-18","eqid":"2013092317351996072634767"}]}';


    var obj = jQuery.parseJSON(strJson);


    //取值
     alert(obj.XXOOSS[0].eqsn);

#5


首先确保引用了JQuery!
再测试取值: var obj = jQuery.parseJSON(strJson);
     alert(obj.XXOOSS[0].eqsn); !

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2019 ITdaan.com

赞助商广告