Package com.google.gson
Interface JsonSerializationContext
- All Known Implementing Classes:
TreeTypeAdapter.GsonContextImpl
public interface JsonSerializationContext
Context for serialization that is passed to a custom serializer during invocation of its
JsonSerializer.serialize(Object, Type, JsonSerializationContext)
method.-
Method Summary
Modifier and TypeMethodDescriptionInvokes default serialization on the specified object.Invokes default serialization on the specified object passing the specific type information.
-
Method Details
-
serialize
Invokes default serialization on the specified object.- Parameters:
src
- the object that needs to be serialized.- Returns:
- a tree of
JsonElement
s corresponding to the serialized form ofsrc
.
-
serialize
Invokes 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.- Parameters:
src
- the object that needs to be serialized.typeOfSrc
- the actual genericized type of src object.- Returns:
- a tree of
JsonElement
s corresponding to the serialized form ofsrc
.
-