public class GsonAdapter<T> extends Object implements com.google.gson.JsonSerializer<T>, com.google.gson.JsonDeserializer<T>
Adapted from http://blog.xurmo.ai/2014/03/03/handle-java-interfaces-using-gson/.
To be used with:
gsonBuilder.registerTypeHierarchyAdapter(T, new GsonAdapter());
| Constructor and Description |
|---|
GsonAdapter() |
| Modifier and Type | Method and Description |
|---|---|
T |
deserialize(com.google.gson.JsonElement json,
Type typeOfT,
com.google.gson.JsonDeserializationContext context) |
com.google.gson.JsonElement |
serialize(T src,
Type typeOfSrc,
com.google.gson.JsonSerializationContext serContext) |
public T deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
deserialize in interface com.google.gson.JsonDeserializer<T>com.google.gson.JsonParseExceptionCopyright © 2015 Red Hat, Inc.. All rights reserved.