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

org.devlive.sdk.openai.utils.JsonUtils Maven / Gradle / Ivy

Go to download

Provides an easy-to-use SDK for Java developers to interact with the APIs of open AI models.

There is a newer version: 2024.01.3
Show newest version
package org.devlive.sdk.openai.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtils
{
    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

    private JsonUtils()
    {
    }

    public static JsonUtils getInstance()
    {
        return new JsonUtils();
    }

    public T getObject(String json, Class clazz) throws JsonProcessingException
    {
        return OBJECT_MAPPER.readValue(json, clazz);
    }

    public String getString(T clazz) throws JsonProcessingException
    {
        return OBJECT_MAPPER.writeValueAsString(clazz);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy