![JAR search and dependency download from the Maven repository](/logo.png)
org.kairosdb.client.JsonMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client Show documentation
Show all versions of client Show documentation
Java client for pushing and querying data to/from KairosDB
package org.kairosdb.client;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.kairosdb.client.deserializer.GroupByDeserializer;
import org.kairosdb.client.deserializer.ResultsDeserializer;
import org.kairosdb.client.response.GroupResult;
import org.kairosdb.client.response.Results;
import java.io.Reader;
import java.lang.reflect.Type;
public class JsonMapper
{
private Gson mapper;
public JsonMapper(DataPointTypeRegistry typeRegistry)
{
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(GroupResult.class, new GroupByDeserializer());
builder.registerTypeAdapter(Results.class, new ResultsDeserializer(typeRegistry));
mapper = builder.create();
}
public T fromJson(Reader json, Type typeOfT)
{
return mapper.fromJson(json, typeOfT);
}
public T fromJson(String json, Type typeOfT)
{
return mapper.fromJson(json, typeOfT);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy