+ -
当前位置:首页 → 问答吧 → 不得已,问一下如何查看JSON的数组是否正确

不得已,问一下如何查看JSON的数组是否正确

时间:2009-07-14

来源:互联网

想来会JQUERY的一般对JS都很了解,特地来问一下
下面这个,用ALERT老是输出未定义;但是从内容上看这个数组太麻烦了,有什么简便的方法吗

<script>
        rank='{"gold":[{"0":"98391","gold":"98391","1":"1","id":"1","2":"1","level":"1","3":"100","rmb":"100","4":"192","exp":"192","5":"0","cards":"0","packages":[],"title":"250158575","name":"u59dau4e39u59b9","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090420/0015/tiny_A1iI_96990e204236.jpg"},{"0":"10873","gold":"10873","1":"6","id":"6","2":"3","level":"3","3":"55","rmb":"55","4":"1010","exp":"1010","5":"0","cards":"0","packages":[],"title":"250178028","name":"u5434u7acbu51b0","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090528/0255/tiny_zH88_34985l204237.jpg"},{"0":"4200","gold":"4200","1":"20","id":"20","2":"3","level":"3","3":"924","rmb":"924","4":"1629","exp":"1629","5":"1","cards":"1","packages":[],"title":"267814245","name":"u59dau7476","tinyurl":"http://hdn211.xnimg.cn/photos/hdn211/20090228/17/40/tiny_il84_58678h204238.jpg"},{"0":"314","gold":"314","1":"9","id":"9","2":"1","level":"1","3":"100","rmb":"100","4":"17","exp":"17","5":"0","cards":"0","packages":[],"title":"266747372","name":"u8d3eu4e00u4ec1","tinyurl":"http://hdn511.xnimg.cn/photos/hdn511/20090217/11/05/tiny_7Qke_63414a204234.jpg"},{"0":"305","gold":"305","1":"24","id":"24","2":"1","level":"1","3":"0","rmb":"0","4":"0","exp":"0","5":"0","cards":"0","packages":[],"title":"233315209","name":"u5f90u9a8f","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090326/06/30/tiny_qFpg_236625h204238.jpg"},{"0":"300","gold":"300","1":"29","id":"29","2":"1","level":"1","3":"0","rmb":"0","4":"0","exp":"0","5":"0","cards":"0","packages":[]},{"0":"200","gold":"200","1":"10","id":"10","2":"1","level":"1","3":"1000","rmb":"1000","4":"0","exp":"0","5":"0","cards":"0","packages":"","title":"267694696","name":"u5434u4e50","tinyurl":"http://hdn411.xnimg.cn/photos/hdn411/20090228/02/35/tiny_xwuI_51536b204235.jpg"},{"0":"157","gold":"157","1":"8","id":"8","2":"1","level":"1","3":"100","rmb":"100","4":"7","exp":"7","5":"0","cards":"0","packages":[],"title":"273240639","name":"u5434u9521u840d","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090428/0930/tiny_HhTk_43797e204235.jpg"},{"0":"154","gold":"154","1":"7","id":"7","2":"1","level":"1","3":"100","rmb":"100","4":"20","exp":"20","5":"0","cards":"0","packages":[],"title":"273123861","name":"u6bb5u797au534e","tinyurl":"http://hdn211.xnimg.cn/photos/hdn211/20090525/0050/tiny_u210_50257d204235.jpg"},{"0":"40","gold":"40","1":"25","id":"25","2":"1","level":"1","3":"0","rmb":"0","4":"177","exp":"177","5":"0","cards":"0","packages":[],"title":"242856120","name":"u6768u5cf0","tinyurl":"http://hdn511.xnimg.cn/photos/hdn511/20090521/0715/tiny_EQlI_37052m204235.jpg"}],"exp":[{"0":"4200","gold":"4200","1":"20","id":"20","2":"3","level":"3","3":"924","rmb":"924","4":"1629","exp":"1629","5":"1","cards":"1","packages":[],"title":"267814245","name":"u59dau7476","tinyurl":"http://hdn211.xnimg.cn/photos/hdn211/20090228/17/40/tiny_il84_58678h204238.jpg"},{"0":"10873","gold":"10873","1":"6","id":"6","2":"3","level":"3","3":"55","rmb":"55","4":"1010","exp":"1010","5":"0","cards":"0","packages":[],"title":"250178028","name":"u5434u7acbu51b0","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090528/0255/tiny_zH88_34985l204237.jpg"},{"0":"98391","gold":"98391","1":"1","id":"1","2":"1","level":"1","3":"100","rmb":"100","4":"192","exp":"192","5":"0","cards":"0","packages":[],"title":"250158575","name":"u59dau4e39u59b9","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090420/0015/tiny_A1iI_96990e204236.jpg"},{"0":"40","gold":"40","1":"25","id":"25","2":"1","level":"1","3":"0","rmb":"0","4":"177","exp":"177","5":"0","cards":"0","packages":[],"title":"242856120","name":"u6768u5cf0","tinyurl":"http://hdn511.xnimg.cn/photos/hdn511/20090521/0715/tiny_EQlI_37052m204235.jpg"},{"0":"154","gold":"154","1":"7","id":"7","2":"1","level":"1","3":"100","rmb":"100","4":"20","exp":"20","5":"0","cards":"0","packages":[],"title":"273123861","name":"u6bb5u797au534e","tinyurl":"http://hdn211.xnimg.cn/photos/hdn211/20090525/0050/tiny_u210_50257d204235.jpg"},{"0":"314","gold":"314","1":"9","id":"9","2":"1","level":"1","3":"100","rmb":"100","4":"17","exp":"17","5":"0","cards":"0","packages":[],"title":"266747372","name":"u8d3eu4e00u4ec1","tinyurl":"http://hdn511.xnimg.cn/photos/hdn511/20090217/11/05/tiny_7Qke_63414a204234.jpg"},{"0":"157","gold":"157","1":"8","id":"8","2":"1","level":"1","3":"100","rmb":"100","4":"7","exp":"7","5":"0","cards":"0","packages":[],"title":"273240639","name":"u5434u9521u840d","tinyurl":"http://hdn311.xnimg.cn/photos/hdn311/20090428/0930/tiny_HhTk_43797e204235.jpg"},{"0":"300","gold":"300","1":"29","id":"29","2":"1","level":"1","3":"0","rmb":"0","4":"0","exp":"0","5":"0","cards":"0","packages":[]}],"cards":[{"0":"4200","gold":"4200","1":"20","id":"20","2":"3","level":"3","3":"924","rmb":"924","4":"1629","exp":"1629","5":"1","cards":"1","packages":[],"title":"267814245"},{"0":"300","gold":"300","1":"29","id":"29","2":"1","level":"1","3":"0","rmb":"0","4":"0","exp":"0","5":"0","cards":"0","packages":[]}]}';
    
    alert(rank.gold);
</script>


作者: orclord   发布时间: 2009-07-14

多了个引号,把2端的引号去掉,或者eval一下

作者: keakon   发布时间: 2009-07-14

学了一招.呵呵.

作者: hotdigger   发布时间: 2009-09-11

相关阅读 更多