Class JacksonJSONSerializer
java.lang.Object
dk.cloudcreate.essentials.components.foundation.json.JacksonJSONSerializer
- All Implemented Interfaces:
JSONSerializer
Jackson
ObjectMapper based JSONSerializer-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.databind.ObjectMapper -
Constructor Summary
ConstructorsConstructorDescriptionJacksonJSONSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescription<T> Tdeserialize(byte[] json, Class<T> javaType) Deserialize the payload in thejsonparameter into the Java type specified by thejavaTypeparameter<T> Tdeserialize(byte[] json, String javaType) Deserialize the payload in thejsonparameter into the Java type specified by the Fully Qualified Class Name contained in thejavaTypeparameter<T> Tdeserialize(String json, Class<T> javaType) Deserialize the payload in thejsonparameter into the Java type specified by thejavaTypeparameter<T> Tdeserialize(String json, String javaType) Deserialize the payload in thejsonparameter into the Java type specified by the Fully Qualified Class Name contained in thejavaTypeparameterGet theClassLoaderused for serializing to JSON and deserializing from JSON
Note: MUST not be nullcom.fasterxml.jackson.databind.ObjectMapperDirect access to the internalObjectMapperused by theJacksonJSONSerializer(or subclasses)Serialize the object to JSONbyte[]serializeAsBytes(Object obj) Serialize the object to JSONvoidsetClassLoader(ClassLoader classLoader) Set theClassLoaderused for serializing to JSON and deserializing from JSON.
-
Field Details
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
JacksonJSONSerializer
public JacksonJSONSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
serialize
Description copied from interface:JSONSerializerSerialize the object to JSON- Specified by:
serializein interfaceJSONSerializer- Parameters:
obj- the object to serialize- Returns:
- the serialized json payload as a String
-
serializeAsBytes
Description copied from interface:JSONSerializerSerialize the object to JSON- Specified by:
serializeAsBytesin interfaceJSONSerializer- Parameters:
obj- the object to serialize- Returns:
- the serialized json payload as a byte[]
-
deserialize
Description copied from interface:JSONSerializerDeserialize the payload in thejsonparameter into the Java type specified by the Fully Qualified Class Name contained in thejavaTypeparameter- Specified by:
deserializein interfaceJSONSerializer- Type Parameters:
T- the corresponding Java type- Parameters:
json- the json payloadjavaType- the Fully Qualified Class Name for the Java type that the json payload should be deserialized into- Returns:
- the deserialized json payload
-
deserialize
Description copied from interface:JSONSerializerDeserialize the payload in thejsonparameter into the Java type specified by thejavaTypeparameter- Specified by:
deserializein interfaceJSONSerializer- Type Parameters:
T- the corresponding Java type- Parameters:
json- the json payloadjavaType- the Java type that the json payload should be deserialized into- Returns:
- the deserialized json payload
-
deserialize
Description copied from interface:JSONSerializerDeserialize the payload in thejsonparameter into the Java type specified by the Fully Qualified Class Name contained in thejavaTypeparameter- Specified by:
deserializein interfaceJSONSerializer- Type Parameters:
T- the corresponding Java type- Parameters:
json- the json payloadjavaType- the Fully Qualified Class Name for the Java type that the json payload should be deserialized into- Returns:
- the deserialized json payload
-
deserialize
Description copied from interface:JSONSerializerDeserialize the payload in thejsonparameter into the Java type specified by thejavaTypeparameter- Specified by:
deserializein interfaceJSONSerializer- Type Parameters:
T- the corresponding Java type- Parameters:
json- the json payloadjavaType- the Java type that the json payload should be deserialized into- Returns:
- the deserialized json payload
-
getClassLoader
Description copied from interface:JSONSerializerGet theClassLoaderused for serializing to JSON and deserializing from JSON
Note: MUST not be null- Specified by:
getClassLoaderin interfaceJSONSerializer- Returns:
- the
ClassLoaderused for serializing to JSON and deserializing from JSON
-
setClassLoader
Description copied from interface:JSONSerializerSet theClassLoaderused for serializing to JSON and deserializing from JSON. This is e.g. required to support SpringBoot DevTools- Specified by:
setClassLoaderin interfaceJSONSerializer- Parameters:
classLoader- theClassLoaderused for serializing to JSON and deserializing from JSON
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Direct access to the internalObjectMapperused by theJacksonJSONSerializer(or subclasses)- Returns:
- the internal
ObjectMapper
-