首页 > 解决方案 > Google playstore gson 序列化与本地安装的 gson 序列化不同

问题描述

我有这门课

public class _CtV3 {
    private long   _ct_id;
    private String _ct_eml;
    private int    _ct_lst;
    private int    _ct_til;
    private String _ct_gid;
    private int    _ct_ntr;
    private int    _ct_nle;
    private int    _ct_nlm;
    private String _ct_uui;

    public _CtV3(long ct_id, String ct_eml, int ct_lst, int ct_til, String ct_gid, int ct_ntr, int ct_nle, int ct_nlm, String ct_uui) {
        this._ct_id  = ct_id;
        this._ct_eml = ct_eml;
        this._ct_lst = ct_lst;
        this._ct_til = ct_til;
        this._ct_gid = ct_gid;
        this._ct_ntr = ct_ntr;
        this._ct_nle = ct_nle;
        this._ct_nlm = ct_nlm;
        this._ct_uui = ct_uui;
    }
    ...
}

在某些时候用 Gson 序列化...

 String uuid = UUID.randomUUID().toString();
 ctV3 = new _CtV3(0, "", 0, 0, "", 0, -1, 0, uuid);

 GsonBuilder builder = new GsonBuilder();
 Gson gson = builder.create();
 String dec = gson.toJson(ctV3);

 Log.d(TAG, dec);

现在的问题。如果我直接从 Android Studio 安装在 Android 手机上,一切正常并返回日志

{"_ct_eml":"","_ct_gid":"","_ct_id":0,"_ct_lst":0,"_ct_nle":-1,"_ct_nlm":0,"_ct_ntr":0,"_ct_til":0,"_ct_uui":"f0438604-a22b-44d3-bb4b-9303a828b0f9"}

如果我从 Google PlayStore 安装在同一部手机上,则返回相同的日志

{"a":0,"b":"","c":0,"d":0,"e":0,"f":-1,"g":0,"h":"19ff09be-07d1-411d-a625-bcf4b574abec"}

这个问题上个月出现了,因为我的最后一次升级是在 9 月初进行的。

标签: androidgson

解决方案


推荐阅读