search

Home  >  Q&A  >  body text

android - 用Gson解析Json字符串数组的问题?

    {
    "date":"2016-3-21",
    "info":{
    "kongtiao":[
    "较少开启",
    "您将感到很舒适,一般不需要开启空调。"
    ],
    "yundong":[
    "较不宜",
    "有降水,推荐您在室内进行健身休闲运动;若坚持户外运动,须注意携带雨具并注意避雨防滑。"
    ],
    "ziwaixian":[
    "最弱",
    "属弱紫外线辐射天气,无需特别防护。若长期在户外,建议涂擦SPF在8-12之间的防晒护肤品。"
    ],
    "ganmao":[
    "易发",
    "天冷空气湿度大,易发生感冒,请注意适当增加衣服,加强自我防护避免感冒。"
    ],
    "xiche":[
    "不宜",
    "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。"
    ]
    }
    }
    
    
它里面的值是[]字符串数组,那我要在Bean中用什么数据类型表示呢?
巴扎黑巴扎黑2772 days ago586

reply all(5)I'll reply

  • 高洛峰

    高洛峰2017-04-17 16:20:58

    ArrayList

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:20:58

    Character array String[]

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 16:20:58

    Both types are available

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 16:20:58

    /* date : 2016-3-21 * info :
    {"kongtiao":["Turn on less","You will feel very comfortable and generally do not need to turn on the air conditioner."],"yundong":[" It is less suitable","There is precipitation, it is recommended that you do fitness and leisure sports indoors; if you insist on outdoor sports, you must bring rain gear and pay attention to avoid rain and prevent slipping. "],"ziwaixian":["Weakest","It is a weak ultraviolet radiation. No special protection is required depending on the weather. If you stay outdoors for a long time, it is recommended to apply sunscreen and skin care products with an SPF of 8-12. Please add appropriate clothing and strengthen self-protection to avoid catching a cold. "],"xiche":["Not suitable","It is not suitable to wash your car. It will rain in the next 24 hours. If you wash your car during this period, the rain and muddy water on the road may come back. Dirty your car "]}
    */

    private String date; private InfoEntity info;

    public void setDate(String date) {

    this.date = date; }
    

    public void setInfo(InfoEntity info) {

    this.info = info; }
    

    public String getDate() {

    return date; }
    

    public InfoEntity getInfo() {

    return info; }
    

    public static class InfoEntity {

    private List<String> kongtiao;
    private List<String> yundong;
    private List<String> ziwaixian;
    private List<String> ganmao;
    private List<String> xiche;
    
    public void setKongtiao(List<String> kongtiao) {
        this.kongtiao = kongtiao;
    }
    
    public void setYundong(List<String> yundong) {
        this.yundong = yundong;
    }
    
    public void setZiwaixian(List<String> ziwaixian) {
        this.ziwaixian = ziwaixian;
    }
    
    public void setGanmao(List<String> ganmao) {
        this.ganmao = ganmao;
    }
    
    public void setXiche(List<String> xiche) {
        this.xiche = xiche;
    }
    
    public List<String> getKongtiao() {
        return kongtiao;
    }
    
    public List<String> getYundong() {
        return yundong;
    }
    
    public List<String> getZiwaixian() {
        return ziwaixian;
    }
    
    public List<String> getGanmao() {
        return ganmao;
    }
    
    public List<String> getXiche() {
        return xiche;
    } }

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 16:20:58

    List<String> kongtiao = new ArrayList<>();

    reply
    0
  • Cancelreply