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

ml.comet.experiment.utils.JsonUtils Maven / Gradle / Ivy

There is a newer version: 1.1.14
Show newest version
package ml.comet.experiment.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;

@UtilityClass
public class JsonUtils {

    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

    @SneakyThrows
    public String toJson(Object object) {
        return OBJECT_MAPPER.writeValueAsString(object);
    }

    @SneakyThrows
    public  T fromJson(String json, Class clazz) {
        return OBJECT_MAPPER.readValue(json, clazz);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy