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

cz.mmsparams.api.json.JsonUtils Maven / Gradle / Ivy

The newest version!
package cz.mmsparams.api.json;

import com.google.gson.Gson;

import java.io.Reader;

public class JsonUtils
{
    private JsonUtils()
    {
    }

    private static final Gson objectMapper = new Gson();

    public static  T fromJson(byte[] serialized, Class clazz)
    {
        return fromJson(new String(serialized), clazz);
    }

    public static  T fromJson(String serialized, Class clazz)
    {
        return objectMapper.fromJson(serialized, clazz);
    }

    public static  T fromJson(Reader serialized, Class clazz)
    {
        return objectMapper.fromJson(serialized, clazz);
    }

    public static String toJson(Object object)
    {
        return objectMapper.toJson(object);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy