
nl.pvanassen.highchart.api.serializer.Serializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of highchart-java-api Show documentation
Show all versions of highchart-java-api Show documentation
A Java API to generate highchart json on the server side.
The newest version!
package nl.pvanassen.highchart.api.serializer;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Map.Entry;
import com.google.gson.*;
public abstract class Serializer implements JsonSerializer {
public Serializer() {
super();
}
public abstract Map getProperties(K instance);
@Override
public JsonElement serialize(K instance, Type arg1, JsonSerializationContext arg2) {
Map map = getProperties(instance);
if (map == null) {
return new JsonPrimitive("");
}
JsonObject r = new JsonObject();
for (Entry e : map.entrySet()) {
r.addProperty(e.getKey(), e.getValue());
}
return r;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy