{"pages":"1","total":"1","code":"200","msg":"success","mode":"getbidlist","data": [{"info":"","currentlyuserid":"当前领先","domain":"jxshop.com","lefttime":"2 天6小时14分20秒","begindate":"2012-9-10 8:00:00","destinenum":"0","hits":"6","currentlyprice":"110","enddate":"2012-9-27 21:00:00","bidtimes":"3","beginprice":"70"}]}。例如有上面一串json数据,我想获取“data”键对应的value中[{"info":"","currentlyuserid":"当前领先","domain":"jxshop.com","lefttime":"2 天6小时14分20秒","begindate":"2012-9-10 8:00:00","destinenum":"0","hits":"6","currentlyprice":"110","enddate":"2012-9-27 21:00:00","bidtimes":"3","beginprice":"70"}]的各个键对应的值,用js和jquery分别怎么获取到啊?我知道可以用var obj=Jquery.parseJson(Str);然后obj.data能够获取value的值
的各个键对应的值,用js和jquery分别怎么获取到啊?我知道可以用var obj=Jquery.parseJson(Str);然后obj.data能够获取value的值
你都知道了,你还想问啥,$.parseJSON 后,就是一个对象,里面可能是对象包含对象,可能是数组,如果是数组就循环,是 属性,就直接取呗 !
就是说若我想取data键对应value值中的的info键对应的值可以用obj.data.info??这样来取吗???
@让手指在键盘上飞舞:
不行,你的 data 是一个 数组 ,所以需要 obj.data[index].info 这样,
就像我上面说的,如果是对象,就直接取,如果是数组就循环,弄清楚你当前的每个是啥数据类型,结构!
非常谢谢
就是用jquery.json插件
或者有个json2.js