All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cl.transbank.util.JsonUtilImpl Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package cl.transbank.util;

import com.google.gson.Gson;

public final class JsonUtilImpl implements JsonUtil {
    private static volatile JsonUtilImpl instance;
    private Gson gson;

    private JsonUtilImpl() {
        super();
        gson = new Gson();
    }

    public String jsonEncode(Object o) {
        return gson.toJson(o);
    }

    public  T jsonDecode(String json, Class clazz) {
        return gson.fromJson(json, clazz);
    }

    public static JsonUtilImpl getInstance() {
        if (null == instance) {
            synchronized (JsonUtilImpl.class) {
                instance = new JsonUtilImpl();
            }
        }

        return instance;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy