怎么样使用java来获得百度地图开源接口中,IP定位返回的结果?
例如:访问:http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=202...
例如:
访问:http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=202.198.16.3&coor=bd09ll
返回了:
{"address":"CN|\u5409\u6797|\u957f\u6625|None|CERNET|1|None","content":{"address":"\u5409\u6797\u7701\u957f\u6625\u5e02","address_detail":{"city":"\u957f\u6625\u5e02","city_code":53,"district":"","province":"\u5409\u6797\u7701","street":"","street_number":""},"point":{"x":"125.31364243","y":"43.89833761"}},"status":0}
如何把address的值\u5409\u6797\u7701\u957f\u6625\u5e02放入变量str中?
求高手们解答。。
大神们回答得太好了,我已经下载了jar包,但是我不太会定义那个类,里面有包含关系,还麻烦大家再帮我把,谢谢啦! 展开
访问:http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=202.198.16.3&coor=bd09ll
返回了:
{"address":"CN|\u5409\u6797|\u957f\u6625|None|CERNET|1|None","content":{"address":"\u5409\u6797\u7701\u957f\u6625\u5e02","address_detail":{"city":"\u957f\u6625\u5e02","city_code":53,"district":"","province":"\u5409\u6797\u7701","street":"","street_number":""},"point":{"x":"125.31364243","y":"43.89833761"}},"status":0}
如何把address的值\u5409\u6797\u7701\u957f\u6625\u5e02放入变量str中?
求高手们解答。。
大神们回答得太好了,我已经下载了jar包,但是我不太会定义那个类,里面有包含关系,还麻烦大家再帮我把,谢谢啦! 展开
3个回答
2013-08-27
展开全部
gson,先按 那格式,定义一个类BaiduGeo
Gson gson = new Gson();
result = gson.fromJson(sTotalString, BaiduGeo.class);
Gson gson = new Gson();
result = gson.fromJson(sTotalString, BaiduGeo.class);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上是正解啊,json的转成map格式,然后用键值对的形式取出来就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
额 这个就是json的啦
var s = '{"address":"CN|\u5409\u6797|\u957f\u6625|None|CERNET|1|None","content":{"address":"\u5409\u6797\u7701\u957f\u6625\u5e02","address_detail":{"city":"\u957f\u6625\u5e02","city_code":53,"district":"","province":"\u5409\u6797\u7701","street":"","street_number":""},"point":{"x":"125.31364243","y":"43.89833761"}},"status":0}';
var jsonObj = eval("("+s+")");
你就可以得到的啦
就是的啦
var str = jsonObj.address;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询