
com.intellifylearning.gson.BasePayloadSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of intellisense Show documentation
Show all versions of intellisense Show documentation
IntelliSense Sensor API for Java
package com.intellifylearning.gson;
import java.lang.reflect.Type;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.intellifylearning.models.BasePayload;
/**
* @author pnayak
*
*/
public class BasePayloadSerializer implements JsonSerializer {
private static final String CLASSNAME = "class";
private static final String INSTANCE = "@instance";
@Override
public JsonElement serialize(BasePayload src, Type typeofSource,
JsonSerializationContext context) {
// JsonObject retValue = new JsonObject();
String className = src.getClass().getCanonicalName();
JsonElement elem = context.serialize(src);
JsonObject retValue = elem.getAsJsonObject();
retValue.addProperty(CLASSNAME, "class " + className);
return retValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy