package com.xxx.xxx; import com.google.gson.Gson; import java.lang.ref.WeakReference; /** * Created by easyboot. * on Date: 2021/8/16 Time: 9:46 */ public class GSON { private static WeakReference<Gson> instance; private GSON(){ } public static Gson get() { if (instance == null || instance.get() == null) { Gson gson = new Gson(); instance = new WeakReference<>(gson); } return instance.get(); } }