public interface JsonTypeAdapter<T>
ValueType eligible for deserialization should have a no-argument constructor (public or private).
Implementation shouldn't take care about nulls (nulls are handled by Gson engine)
For implementation example see LocalDateTimeTypeAdapter.
LocalDateTimeTypeAdapter,
JsonConverter| Modifier and Type | Method and Description |
|---|---|
T |
fromJson(com.google.gson.JsonElement json,
com.google.gson.JsonDeserializationContext jsonDeserializationContext) |
List<Class> |
getValueTypes()
Target classes.
|
com.google.gson.JsonElement |
toJson(T sourceValue,
com.google.gson.JsonSerializationContext jsonSerializationContext) |
T fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext)
json - not null and not JsonNulljsonDeserializationContext - use it to invoke default deserialization on the specified objectcom.google.gson.JsonElement toJson(T sourceValue, com.google.gson.JsonSerializationContext jsonSerializationContext)
sourceValue - not nulljsonSerializationContext - use it to invoke default serialization on the specified objectCopyright © 2014. All rights reserved.