Top Description Methods
com.google.gson

public Interface JsonSerializationContext

Known Direct Implementers
com.google.gson.internal.bind.TreeTypeAdapter.GsonContextImpl
Imports
java.lang.reflect.Type

Context for serialization that is passed to a custom serializer during invocation of its JsonSerializer#serialize(Object, Type, JsonSerializationContext) method.
Authors
Inderjeet Singh, Joel Leitch

Method Summary

Modifier and TypeMethod and Description
public JsonElement

Returns:

a tree of JsonElements corresponding to the serialized form of src.
serialize
(Object
the object that needs to be serialized.
src
)

Invokes default serialization on the specified object.

public JsonElement

Returns:

a tree of JsonElements corresponding to the serialized form of src.
serialize
(Object
the object that needs to be serialized.
src
,
Type
the actual genericized type of src object.
typeOfSrc
)

Invokes default serialization on the specified object passing the specific type information.

Method Detail

serializeback to summary
public JsonElement serialize(Object src)

Invokes default serialization on the specified object.

Parameters
src:Object

the object that needs to be serialized.

Returns:JsonElement

a tree of JsonElements corresponding to the serialized form of src.

serializeback to summary
public JsonElement serialize(Object src, Type typeOfSrc)

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 the JsonSerializer#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:Object

the object that needs to be serialized.

typeOfSrc:Type

the actual genericized type of src object.

Returns:JsonElement

a tree of JsonElements corresponding to the serialized form of src.