• json串处理2


    请求百度地址坐标: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串也可已这样设置

    只用作记录

  • 相关阅读:
    Git本地windows凭证账号更改
    解决vue ui创建项目很慢的原因
    跨域问题总结
    JS柯里化
    vue diff算法讲解
    当面试官问你闭包时,他究竟想听到些什么?
    JS中的 ==
    必须知道的 prototype, [[prototype]], __proto__
    Deepcopy in Javascript
    http问题整理
  • 原文地址:https://www.cnblogs.com/elsons/p/9040813.html
Copyright © 2020-2023  润新知