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

求jquery解析复杂的json
本帖最后由 u010479137 于 2013-11-25 20:33:53 编辑
jquery遍历items获取值,注意ds_img是有嵌套的,需要获取src的值
求代码求代码。感激不尽。
需要获取:ds_cust的值
ds_discount_price的值
ds_discount_rate的值
ds_exchange7的值
ds_genuine的值
ds_img中的src的值
ds_istmall的值
ds_item_click的值
等等的值。。

jsonp_callback_024707129402396788({"code":200,"pattern":"js","templet":"http:\/\/strip.taobaocdn.com\/tfscom\/T1CHCJXqxhXXXqupbX.js","box":{"width":230,"height":312},"data":{"style":{},"items":[{"ds_cust":1,"ds_discount_price":278.04,"ds_discount_rate":5.57,"ds_exchange7":1,"ds_genuine":1,"ds_img":{"src":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/11256030338050349\/T1GhgKFa8gXXXXXXXX_!!0-item_pic.jpg"},"ds_istmall":1,"ds_item_click":"http:\/\/redirect.simba.taobao.com\/rd?&f=http%3A%2F%2Fre.taobao.com%2Feauction%3Fe%3DYu%252BUZq%252BE0j8jmraEDZVrLpeagkkKGSYinnDOe2U0TNmLltG5xFicOSFINJCCZ52P4s7frdohyhCRM2s%252BZrTbIaWE5NJ1SqvqkI8C07VY7uWB3ujUJI0OeA%253D%253D%26ptype%3D100011&k=e2e107a2b72ca1b1&p=mm_16202226_4352175_14614379&pvid=1385360218_528726r2_713810208&posid=&b=display_1_4_0_0_0&w=unionapijs&c=un","ds_nick":"\u82ad\u9ece\u4f9d\u6a71\u65d7\u8230\u5e97","ds_nid":35139269567,"ds_post24":0,"ds_postfee":0.00,"ds_provcity":"\u5317\u4eac","ds_rank":15,"ds_reserve_price":499.00,"ds_sell":2787,"ds_shipping":0,"ds_shop_click":"http:\/\/redirect.simba.taobao.com\/rd?&f=http%3A%2F%2Fs.click.taobao.com%2Ft%3Fe%3Dm%253D2%2526s%253D9oPM4yClaMccQipKwQzePDAVflQIoZepyK8Cckff7TVuwRIiPOGbYI13E2c6WKHoMMgx22UI05aaroDZm1qrF8xXynX5cjaXaUPEqSnJkJPptOta9uLp6Ce%252FfZXmuVksVHDCoDOdwgo%253D&k=7ca9e08409870ccd&p=mm_16202226_4352175_14614379&pvid=1385360218_528726r2_713810208&posid=&b=display_1_4_0_0_0&w=unionapijs&c=un","ds_shopname":"","ds_taoke":1,"ds_taoke_totalcommi":10514.61,"ds_title":"\u82ad\u9ece\u4f9d\u6a712013\u5988\u5988\u88c5\u51ac\u88c5\u7fbd\u7ed2\u68c9\u8863\u4e2d\u5e74\u5973\u88c5\u52a0\u539a\u5916\u5957\u4e2d\u8001\u5e74\u7fbd\u7ed2\u670d\u5973","ds_totalsales":731,"ds_user_id":272201256}]}})

------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var t='{"code":200,"pattern":"js","templet":"http:\/\/strip.taobaocdn.com\/tfscom\/T1CHCJXqxhXXXqupbX.js","box":{"width":230,"height":312},"data":{"style":{},"items":[{"ds_cust":1,"ds_discount_price":278.04,"ds_discount_rate":5.57,"ds_exchange7":1,"ds_genuine":1,"ds_img":{"src":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/11256030338050349\/T1GhgKFa8gXXXXXXXX_!!0-item_pic.jpg"},"ds_istmall":1,"