日期:2014-05-16  浏览次数:20816 次

这样一个JSON字符串怎么解析?
CSS code

[{"prolist":
[{"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/661338@","programlength":0,"seriesid":"true","tags":"","typeid":3},
 {"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/499229@","programlength":0,"seriesid":"true","tags":"","typeid":3},
 {"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/662417@","programlength":0,"seriesid":"true","tags":"","typeid":3}],
"programtype":"1",
"preference":"言情剧|偶像剧",
"total_results":"10"}]



这个JSON是这样的,本身是以Map在后台格式化的,然后里面第一个key是prolist值是List
剩下的programtype、preference、total_results都是字符串,
我现在要在前台用JS或jQuery将prolist里的值循环显示出来,后面那3个字符串也单独显示出来
可是我怎么也取不到值
JScript code

$.getJSON("ppshow", function(data){
    $.each(data, function(i, item){
        alert(i);
    });
});


我这样写只给弹了个0出来了,难道还是Map不能这样取么?


------解决方案--------------------
本来就只有一条记录啊

JScript code

var json = [{"prolist":
[{"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/661338@","programlength":0,"seriesid":"true","tags":"","typeid":3},
 {"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/499229@","programlength":0,"seriesid":"true","tags":"","typeid":3},
 {"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/662417@","programlength":0,"seriesid":"true","tags":"","typeid":3}],
"programtype":"1",
"preference":"言情剧|偶像剧",
"total_results":"10"}];

alert( json.length )
for( var x in json[0] ){
    alert( json[0][x] )
}

------解决方案--------------------
var json = [{"prolist":
[{"actors":"","addedtime":"","canrecommend":false,"director":"","isadvertisement":false,"keywords":"","name":"","programid":"Umai:SERI/661338@&quo