org.devlive.sdk.openai.utils.JsonUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openai-java-sdk Show documentation
Show all versions of openai-java-sdk Show documentation
Provides an easy-to-use SDK for Java developers to interact with the APIs of open AI models.
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);
}
}