【问题标题】:Gson().fromJson(jsonResult, Myobject.class) return values in 0'sGson().fromJson(jsonResult, Myobject.class) 返回 0 中的值
【发布时间】:2016-02-06 00:21:09
【问题描述】:

我有这个 json

{"FechaUpdateId":1,"FechaSegundos":635902782941643690,"FechaSegundosBC":635902779020935030}

我执行此命令将其转换为对象

FechaUpdate dto  = new Gson().fromJson(json, FechaUpdate.class);

但我得到了这个结果

这是我的 FechaUpdate 课程

public class FechaUpdate {

    public int getFechaUpdateId() {
        return fechaUpdateId;
    }

    public void setFechaUpdateId(int fechaUpdateId) {
        this.fechaUpdateId = fechaUpdateId;
    }

    public long getFechaSegundosBC() {
        return fechaSegundosBC;
    }

    public void setFechaSegundosBC(long fechaSegundosBC) {
        this.fechaSegundosBC = fechaSegundosBC;
    }

    public long getFechaSegundos() {
        return fechaSegundos;
    }

    public void setFechaSegundos(long fechaSegundos) {
        this.fechaSegundos = fechaSegundos;
    }

        private int fechaUpdateId ;
        private long fechaSegundos ;
        private long fechaSegundosBC;



}

【问题讨论】:

    标签: json gson android


    【解决方案1】:

    解决了

    如果你看到我的私人属性,它们就是

            private int fechaUpdateId ;
            private long fechaSegundos ;
            private long fechaSegundosBC;
    

    我改变它们

    private int FechaUpdateId ;
    private long FechaSegundos ;
    private long FechaSegundosBC;
    

    并再次生成 getter 和 setter。 区别是第一个字母是大写。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多