js获取json数据 60
{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317...
{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}
请问怎么用JS取得city county的值 展开
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}
请问怎么用JS取得city county的值 展开
10个回答
展开全部
//javascript
var data = '{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}';
var result=eval('('+data+')');
var country= result.data.country;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var Data = eval('(' + json + ')');var json1 = Data.channel.item; // item是数组var r = "";for (var i = 0; i < json1.length; i++) { var obj = json1[i]; r += obj.title + "" + obj.description; var cateforys = obj.catefory; // catefory是数组 for (var j = 0; j < cateforys.length; j++) { // 中括号方式获取js变量中不允许出现的 var catefory = cateforys[j]; r += catefory["-domain"] + catefory["#text"]; }}alert(r);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var Data = eval('(' + json + ')');var json1 = Data.channel.item; // item是数组var r = "";for (var i = 0; i < json1.length; i++) { var obj = json1[i]; r += obj.title + "" + obj.description; var cateforys = obj.catefory; // catefory是数组 for (var j = 0; j < cateforys.length; j++) { // 中括号方式获取js变量中不允许出现的 var catefory = cateforys[j]; r += catefory["-domain"] + catefory["#text"]; }}alert(r);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var json = {"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}};
alert(json.data.city);
======> 输出“北京市”
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}};
alert(json.data.city);
======> 输出“北京市”
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询