请求百度地址坐标:http://api.map.baidu.com/location/ip?ak=y0Yb5ZgGK9blTDbR7Dwh9jGtn6X1YE48&coor=bd09ll&ip=218.29.180.34
返回结果是这种json串
{ "address": "CN|河南|许昌|None|UNICOM|0|0", "content": { "address_detail": { "province": "河南省", "city": "许昌市", "district": "", "street": "", "street_number": "", "city_code": 155 }, "address": "河南省许昌市", "point": { "y": "4008261.73", "x": "12672226.9" } }, "status": 0 }
1。外面的很好弄,如果是建立实体的话,就是 address,content,status,
2。content 里面包含 address,point,address_detail, 可以看做是另外一个类 。
public class Location { public string ip { set; get; } public string address { set; get; } public int status { set; get; } public content Content { set; get; } public class content { public Dictionary<string, string> point { set; get; } } }
利用dictionary<string,string> 来解析这种数据,然后就可以获取到数据局dic.Content.point["x"] 这种方式获取数据
如果要生成这种json串也可已这样设置
只用作记录