private static final Gson gsonInstance;
static {
gsonInstance = new GsonBuilder().registerTypeAdapter(Double.class, new JsonSerializer<Double>() {
@Override
public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) {
if(src == src.longValue()){
return new JsonPrimitive(src.longValue());
}
return new JsonPrimitive(src);
}
}).create();
}
gson integer (1) is converted to double (1.0) solution
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326530843&siteId=291194637
Ranking