Package com.oracle.coherence.io.json
Class JsonSerializer
- java.lang.Object
-
- com.oracle.coherence.io.json.JsonSerializer
-
- All Implemented Interfaces:
ClassLoaderAware,Serializer
@Named("json") @ApplicationScoped public class JsonSerializer extends Object implements Serializer, ClassLoaderAwareJSON Serializer usingGenson.- Since:
- 20.06
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonSerializer.FactoryFactory for default serializer.
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUG_MODEA flag indicating whether to dump json to the log.protected booleanf_fCompatibleModeFlag indicating Maps should be serialized in a JSON compatible fashion.protected Gensonf_gensonGensonruntime for serialization/deserialization operations.protected WeakReference<ClassLoader>m_refLoaderThe optional ClassLoader.static StringPROP_DEBUG_MODEThe System property to use to dump json being serialized or deserialized to the log.
-
Constructor Summary
Constructors Constructor Description JsonSerializer()Default constructor.JsonSerializer(boolean compatibleMode)Create aJsonSerializer.JsonSerializer(ClassLoader loader)Constructs aGensonJsonSerializerthat will use the providedClassLoader.JsonSerializer(ClassLoader loader, Modifier<GensonBuilder> builderModifier, boolean compatibleMode)Constructs aGensonJsonSerializerthat will use the providedClassLoader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tdeserialize(ReadBuffer.BufferInput in, Class<? extends T> clazz)ClassLoadergetContextClassLoader()StringgetName()voidserialize(WriteBuffer.BufferOutput bufferOutput, Object oValue)voidsetContextClassLoader(ClassLoader classLoader)Gensonunderlying()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tangosol.io.Serializer
deserialize
-
-
-
-
Field Detail
-
PROP_DEBUG_MODE
public static final String PROP_DEBUG_MODE
The System property to use to dump json being serialized or deserialized to the log.- See Also:
- Constant Field Values
-
DEBUG_MODE
public static final boolean DEBUG_MODE
A flag indicating whether to dump json to the log.This will impact performance and should only be used in testing.
-
f_genson
protected final Genson f_genson
Gensonruntime for serialization/deserialization operations.
-
f_fCompatibleMode
protected final boolean f_fCompatibleMode
Flag indicating Maps should be serialized in a JSON compatible fashion. This is useful for the cases when JSON produced by this library needs to be consumed by another JSON parsing library other thanGenson.
-
m_refLoader
protected WeakReference<ClassLoader> m_refLoader
The optional ClassLoader.
-
-
Constructor Detail
-
JsonSerializer
public JsonSerializer()
Default constructor.
-
JsonSerializer
public JsonSerializer(boolean compatibleMode)
Create aJsonSerializer.- Parameters:
compatibleMode-trueif consuming JSON from an endpoint that doesn't use our JSON serialization library.- See Also:
JsonSerializer(ClassLoader, Modifier, boolean)
-
JsonSerializer
public JsonSerializer(ClassLoader loader)
Constructs aGensonJsonSerializerthat will use the providedClassLoader.- Parameters:
loader- theClassLoaderto use during deserialization operations
-
JsonSerializer
public JsonSerializer(ClassLoader loader, Modifier<GensonBuilder> builderModifier, boolean compatibleMode)
Constructs aGensonJsonSerializerthat will use the providedClassLoader.- Parameters:
loader- theClassLoaderto use during deserialization operationsbuilderModifier- theModifierthat will be invoked to allow customization of the serializationcompatibleMode-trueif consuming JSON from an endpoint that doesn't use our JSON serialization library.
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getNamein interfaceSerializer
-
getContextClassLoader
public ClassLoader getContextClassLoader()
- Specified by:
getContextClassLoaderin interfaceClassLoaderAware
-
setContextClassLoader
public void setContextClassLoader(ClassLoader classLoader)
- Specified by:
setContextClassLoaderin interfaceClassLoaderAware
-
serialize
public void serialize(WriteBuffer.BufferOutput bufferOutput, Object oValue) throws IOException
- Specified by:
serializein interfaceSerializer- Throws:
IOException
-
deserialize
public <T> T deserialize(ReadBuffer.BufferInput in, Class<? extends T> clazz) throws IOException
- Specified by:
deserializein interfaceSerializer- Throws:
IOException
-
-