zoukankan      html  css  js  c++  java
  • 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串也可已这样设置

    只用作记录

  • 相关阅读:
    [2010山东ACM省赛] Balloons(搜索)
    [2010山东ACM省赛] Greatest Number(数的组合+二分搜索)
    [ACM] hdu 1213 How Many Tables(并查集)
    C Shuffle Cards
    快速读入输出模板
    J Distance to Work
    E Sort String
    H Diff-prime Pairs
    A PACM Team
    区间 (interval)
  • 原文地址:https://www.cnblogs.com/elsons/p/9040813.html
Copyright © 2011-2022 走看看