Json

作者: 我在等你回复可你没回 | 来源:发表于2019-05-20 14:12 被阅读0次

    Json与javabean转化

    json如下,主要是包括对象,还有数组,对象属性之间用逗号隔开

    {
        "people":{
            "name":"wenfeng",
                    "age":"27",
                    "favor":[
                         "basket",
                         "music"
                     ]
        }
            
    }
    

    javabean对象

    /**
      * Copyright 2019 bejson.com 
      */
    package com.besjon.pojo;
    import java.util.List;
    
    /**
     * Auto-generated: 2019-05-20 14:8:19
     *
     * @author bejson.com (i@bejson.com)
     * @website http://www.bejson.com/java2pojo/
     */
    public class People {
    
        private String name;
        private String age;
        private List<String> favor;
        public void setName(String name) {
             this.name = name;
         }
         public String getName() {
             return name;
         }
    
        public void setAge(String age) {
             this.age = age;
         }
         public String getAge() {
             return age;
         }
    
        public void setFavor(List<String> favor) {
             this.favor = favor;
         }
         public List<String> getFavor() {
             return favor;
         }
    
    }
    

    看和风天气的返回值,得生成多个javabean对象

    {
        "HeWeather6": [
            {
                "basic": {
                    "cid": "CN101010100",
                    "location": "北京",
                    "parent_city": "北京",
                    "admin_area": "北京",
                    "cnty": "中国",
                    "lat": "39.90498734",
                    "lon": "116.40528870",
                    "tz": "8.0"
                },
                "now": {
                    "cond_code": "101",
                    "cond_txt": "多云",
                    "fl": "16",
                    "hum": "73",
                    "pcpn": "0",
                    "pres": "1017",
                    "tmp": "14",
                    "vis": "1",
                    "wind_deg": "11",
                    "wind_dir": "北风",
                    "wind_sc": "微风",
                    "wind_spd": "6"
                },
                "status": "ok",
                "update": {
                    "loc": "2017-10-26 17:29",
                    "utc": "2017-10-26 09:29"
                }
            }
        ]
    }
    

    不太好处理。

    相关文章

      网友评论

          本文标题:Json

          本文链接:https://www.haomeiwen.com/subject/twlkzqtx.html