Since conversion Gson int converted into double cause problems, the use of alternative fastjson

Gson will map into json, if there Integer value map, then will be converted to Double Integer

With several ways to try to resolve invalid, that background is used fastjson, then use fastjsoninstead.

Because many places are using Gson, so just deal with the influential place.

Use fastjson

Import dependence

implementation 'com.alibaba:fastjson:1.2.9'

Confusion

# fastjson
-dontwarn com.alibaba.fastjson.**
-keep class com.alibaba.fastjson.**{*;}

# 忽略泛型
-keepattributes Signature

#保持所有实现 Serializable 接口的类成员
#保持 Serializable 不被混淆
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
        private static final java.io.ObjectStreamField[] serialPersistentFields;
        !static !transient <fields>;
        !private <fields>;
        !private <methods>;
        private void writeObject(java.io.ObjectOutputStream);
        private void readObject(java.io.ObjectInputStream);
        java.lang.Object writeReplace();
        java.lang.Object readResolve();
}

OOM occurred when playing release package, in gradle.propertiesyears plus:

# 增加内存分配大小
org.gradle.jvmargs=-Xmx1024m

use

Will map into json:JSON.toJSONString(resultMap)

After using enough. . How to solve their own problems Gson not have time to study the fine.
If there is a perfect solution, please dumped on the link -

Published 85 original articles · won praise 46 · Views 100,000 +

Guess you like

Origin blog.csdn.net/jingbin_/article/details/100997695