public class JsonDataConverter extends DataConverter
ObjectMapper
parameters.
Note that default configuration used by this class includes class name of the every serialized value into the produced JSON. It is done to support polymorphic types out of the box. But in some cases it might be beneficial to disable polymorphic support as it produces much more concise and portable output.
Constructor and Description |
---|
JsonDataConverter()
Create instance of the converter that uses ObjectMapper with
Feature#FAIL_ON_UNKNOWN_PROPERTIES set to false and
default typing set to ObjectMapper.DefaultTyping.NON_FINAL . |
JsonDataConverter(com.fasterxml.jackson.databind.ObjectMapper mapper)
Create instance of the converter that uses
ObjectMapper
configured externally. |
Modifier and Type | Method and Description |
---|---|
<T> T |
fromData(String serialized,
Class<T> valueType)
Implements conversion of the single value.
|
String |
toData(Object value)
Implements conversion of the single value.
|
public JsonDataConverter()
Feature#FAIL_ON_UNKNOWN_PROPERTIES
set to false
and
default typing set to ObjectMapper.DefaultTyping.NON_FINAL
.public JsonDataConverter(com.fasterxml.jackson.databind.ObjectMapper mapper)
ObjectMapper
configured externally.public String toData(Object value) throws DataConverterException
DataConverter
toData
in class DataConverter
value
- Java value to convert to String.DataConverterException
- if conversion of the value passed as parameter failed for any
reason.public <T> T fromData(String serialized, Class<T> valueType) throws DataConverterException
DataConverter
fromData
in class DataConverter
DataConverterException
- if conversion of the data passed as parameter failed for any
reason.Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.