1、定义一个存储百度API返回json结果对象的类:
注:解析json字符串的方式有很多,无需局限于本文这一种。
public class baidu_location
{
[Serializable]
//存储百度定位API返回结果类
public class AddressForQueryIPFromBaidu {
public string Address { get; set; }
public Content Content { get; set; }
public string Status { get; set; }
}
[Serializable]
public class Content {
public string Address { get; set; }
public Address_Detail Address_Detail { get; set; }
public Point Point { get; set; }
}
[Serializable]
public class Address_Detail {
public string City { get; set; }
public string City_Code { get; set; }
public string District { get; set; }
public string Province { get; set; }
public string Street { get; set; }
public string Street_Number { get; set; }
}

这篇博客介绍了如何在C#中使用百度定位API,包括定义存储返回JSON结果的类,编写定位方法,申请ak的步骤,以及调用API的实例。文章提醒读者可以根据自己的需求调整代码,并提供了相关资源链接。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



