这种JSON数据怎么解析????

[{"krnum":0,"kname":"娱乐","kid":1},{"krnum":0,"kname":"生活","kid":2},{"krnum":0,"kname"... [{"krnum":0,"kname":"娱乐","kid":1},{"krnum":0,"kname":"生活","kid":2},{"krnum":0,"kname":"财经","kid":3},{"krnum":0,"kname":"购物","kid":4},{"krnum":0,"kname":"科技","kid":5},{"krnum":0,"kname":"健康","kid":6},{"krnum":0,"kname":"旅游","kid":7},{"krnum":0,"kname":"体育","kid":8},{"krnum":0,"kname":"军事","kid":9},{"krnum":0,"kname":"文化","kid":10},{"krnum":0,"kname":"其他","kid":11}] 展开
 我来答
zgh26782000
推荐于2016-08-01 · TA获得超过1453个赞
知道小有建树答主
回答量:788
采纳率:0%
帮助的人:501万
展开全部
json就相当于js的数组和对象的结构,你这个最外层是中括号,所以是个数组,数组的每一项是大括号包围的,所以数组每个元素是一个js的对象结构
只要用for循环遍历数组,得到每个对象
js的对象是key:value格式的。所以用 对象.key 方式获取数据的

var list = [{"krnum":0,"kname":"娱乐","kid":1},{"krnum":0,"kname":"生活","kid":2},{"krnum":0,"kname":"财经","kid":3},{"krnum":0,"kname":"购物","kid":4},{"krnum":0,"kname":"科技","kid":5},{"krnum":0,"kname":"健康","kid":6},{"krnum":0,"kname":"旅游","kid":7},{"krnum":0,"kname":"体育","kid":8},{"krnum":0,"kname":"军事","kid":9},{"krnum":0,"kname":"文化","kid":10},{"krnum":0,"kname":"其他","kid":11}];
for(var i=0;i<list.length;i++)
{
var item = list[i];
alert(item.kname)//获取kname的值

}
hntjlj
2013-08-26 · 超过14用户采纳过TA的回答
知道答主
回答量:41
采纳率:100%
帮助的人:34.1万
展开全部
<script language="javascript">
var data = eval('[{"krnum":0,"kname":"娱乐","kid":1},{"krnum":0,"kname":"生活","kid":2},{"krnum":0,"kname":"财经","kid":3},{"krnum":0,"kname":"购物","kid":4},{"krnum":0,"kname":"科技","kid":5},{"krnum":0,"kname":"健康","kid":6},{"krnum":0,"kname":"旅游","kid":7},{"krnum":0,"kname":"体育","kid":8},{"krnum":0,"kname":"军事","kid":9},{"krnum":0,"kname":"文化","kid":10},{"krnum":0,"kname":"其他","kid":11}]');

var View = [];
for(var i=0;i<data.length;i++)
{
View.push("ID:"+data[i].krnum+" ");
View.push("Name"+data[i].kname+" ");
View.push("Kid"+data[i].kid+"\n");
}
alert(View.join(""));
</script>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
就烦条0o
2018-08-01 · 知道合伙人软件行家
就烦条0o
知道合伙人软件行家
采纳数:33315 获赞数:46492
从事多年系统运维,喜欢编写各种小程序和脚本。

向TA提问 私信TA
展开全部
要把你的json代码发上来,这样提问都不知道怎么回答的
你要追问里提问,或者做问题的补充就可以
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式