Class GenericJsonToStringTranslator<T>
java.lang.Object
de.iip_ecosphere.platform.transport.serialization.GenericJsonToStringTranslator<T>
- Type Parameters:
T- the class to be serialized
- All Implemented Interfaces:
InputTypeTranslator<String,,T> OutputTypeTranslator<T,,String> TypeTranslator<T,String>
A simple, generic, reusable JSON serializer.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionImplements a simple generic JSON serializer.GenericJsonToStringTranslator(Class<T> cls, de.iip_ecosphere.platform.support.json.Json mapper) Implements a simple generic JSON serializer. -
Method Summary
Modifier and TypeMethodDescriptionDeserializes a target value into a source value ("input from external").de.iip_ecosphere.platform.support.json.JsonReturns the object mapper, e.g., for further customization.Translates a source value into a target value ("output to external").
-
Field Details
-
mapper
private de.iip_ecosphere.platform.support.json.Json mapper -
cls
-
-
Constructor Details
-
GenericJsonToStringTranslator
Implements a simple generic JSON serializer.- Parameters:
cls- the class to be serialized
-
GenericJsonToStringTranslator
public GenericJsonToStringTranslator(Class<T> cls, de.iip_ecosphere.platform.support.json.Json mapper) Implements a simple generic JSON serializer.- Parameters:
cls- the class to be serializedmapper- the object mapper to use
-
-
Method Details
-
getMapper
public de.iip_ecosphere.platform.support.json.Json getMapper()Returns the object mapper, e.g., for further customization.- Returns:
- the mapper
-
from
Description copied from interface:InputTypeTranslatorDeserializes a target value into a source value ("input from external").- Specified by:
fromin interfaceInputTypeTranslator<String,T> - Parameters:
data- the data to be translated back- Returns:
- the serialized object
- Throws:
IOException- in case that serialization fails
-
to
Description copied from interface:OutputTypeTranslatorTranslates a source value into a target value ("output to external").- Specified by:
toin interfaceOutputTypeTranslator<T,String> - Parameters:
source- the source value to be translated- Returns:
- the target value
- Throws:
IOException- in case that translation fails
-