Interface JSONSerializer
- All Known Implementing Classes:
JacksonJSONSerializer
public interface JSONSerializer
JSON serializer and deserializer
-
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 nullSerialize the object to JSONbyte[]serializeAsBytes(Object obj) Serialize the object to JSONvoidsetClassLoader(ClassLoader classLoader) Set theClassLoaderused for serializing to JSON and deserializing from JSON.
-
Method Details
-
serialize
Serialize the object to JSON- Parameters:
obj- the object to serialize- Returns:
- the serialized json payload as a String
- Throws:
JSONSerializationException- in case the json couldn't be deserialized to the specified java type
-
serializeAsBytes
Serialize the object to JSON- Parameters:
obj- the object to serialize- Returns:
- the serialized json payload as a byte[]
- Throws:
JSONSerializationException- in case the json couldn't be deserialized to the specified java type
-
deserialize
Deserialize the payload in thejsonparameter into the Java type specified by the Fully Qualified Class Name contained in thejavaTypeparameter- 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
- Throws:
JSONDeserializationException- in case the json couldn't be deserialized to the specified java type
-
deserialize
Deserialize the payload in thejsonparameter into the Java type specified by thejavaTypeparameter- 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
- Throws:
JSONDeserializationException- in case the json couldn't be deserialized to the specified java type
-
deserialize
Deserialize the payload in thejsonparameter into the Java type specified by the Fully Qualified Class Name contained in thejavaTypeparameter- 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
- Throws:
JSONDeserializationException- in case the json couldn't be deserialized to the specified java type
-
deserialize
Deserialize the payload in thejsonparameter into the Java type specified by thejavaTypeparameter- 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
- Throws:
JSONDeserializationException- in case the json couldn't be deserialized to the specified java type
-
getClassLoader
ClassLoader getClassLoader()Get theClassLoaderused for serializing to JSON and deserializing from JSON
Note: MUST not be null- Returns:
- the
ClassLoaderused for serializing to JSON and deserializing from JSON
-
setClassLoader
Set theClassLoaderused for serializing to JSON and deserializing from JSON. This is e.g. required to support SpringBoot DevTools- Parameters:
classLoader- theClassLoaderused for serializing to JSON and deserializing from JSON
-