Package com.google.gson.internal.bind
Class TreeTypeAdapter.GsonContextImpl
java.lang.Object
com.google.gson.internal.bind.TreeTypeAdapter.GsonContextImpl
- All Implemented Interfaces:
JsonDeserializationContext,JsonSerializationContext
- Enclosing class:
- TreeTypeAdapter<T>
private final class TreeTypeAdapter.GsonContextImpl
extends Object
implements JsonSerializationContext, JsonDeserializationContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<R> Rdeserialize(JsonElement json, Type typeOfT) Invokes default deserialization on the specified object.Invokes default serialization on the specified object.Invokes default serialization on the specified object passing the specific type information.
-
Constructor Details
-
GsonContextImpl
private GsonContextImpl()
-
-
Method Details
-
serialize
Description copied from interface:JsonSerializationContextInvokes default serialization on the specified object.- Specified by:
serializein interfaceJsonSerializationContext- Parameters:
src- the object that needs to be serialized.- Returns:
- a tree of
JsonElements corresponding to the serialized form ofsrc.
-
serialize
Description copied from interface:JsonSerializationContextInvokes default serialization on the specified object passing the specific type information. It should never be invoked on the element received as a parameter of theJsonSerializer.serialize(Object, Type, JsonSerializationContext)method. Doing so will result in an infinite loop since Gson will in-turn call the custom serializer again.- Specified by:
serializein interfaceJsonSerializationContext- Parameters:
src- the object that needs to be serialized.typeOfSrc- the actual genericized type of src object.- Returns:
- a tree of
JsonElements corresponding to the serialized form ofsrc.
-
deserialize
Description copied from interface:JsonDeserializationContextInvokes default deserialization on the specified object. It should never be invoked on the element received as a parameter of theJsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)method. Doing so will result in an infinite loop since Gson will in-turn call the custom deserializer again.- Specified by:
deserializein interfaceJsonDeserializationContext- Type Parameters:
R- The type of the deserialized object.- Parameters:
json- the parse tree.typeOfT- type of the expected return value.- Returns:
- An object of type typeOfT.
- Throws:
JsonParseException- if the parse tree does not contain expected data.
-