public class JacksonObjectToJsonConverter extends java.lang.Object implements ObjectToJsonConverter
ObjectToJsonConverter
implementation using Jackson's ObjectMapper
to convert
from an Object
to a JSON String
.JsonTypeInfo
,
JsonGenerator
,
ObjectMapper
,
MapperFeature
,
TypeDescriptor
,
ObjectToJsonConverter
,
PdxInstanceWrapper
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
AT_TYPE_METADATA_PROPERTY_NAME |
Constructor and Description |
---|
JacksonObjectToJsonConverter() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
convert(java.lang.Object source)
Converts the given
Object into JSON . |
protected java.lang.String |
convertObjectToJson(java.lang.Object source)
Converts the given
Object into JSON . |
protected com.fasterxml.jackson.databind.ObjectMapper |
newObjectMapper(java.lang.Object target)
Constructs a new instance of the Jackson
ObjectMapper class. |
protected static final java.lang.String AT_TYPE_METADATA_PROPERTY_NAME
@NonNull public java.lang.String convert(@NonNull java.lang.Object source)
Object
into JSON
.convert
in interface org.springframework.core.convert.converter.Converter<java.lang.Object,java.lang.String>
source
- Object
to convert into JSON
.JSON
generated from the given Object
using Jackson's ObjectMapper
.java.lang.IllegalArgumentException
- if source
is null.org.springframework.core.convert.ConversionFailedException
- if a JsonProcessingException
is thrown or another error occurs
while trying to convert the given Object
to JSON
.ObjectMapper
,
convertObjectToJson(Object)
@NonNull protected java.lang.String convertObjectToJson(@NonNull java.lang.Object source) throws com.fasterxml.jackson.core.JsonProcessingException
Object
into JSON
.source
- Object
to convert to JSON
; must not be null.JSON
generated from the given Object
.java.lang.IllegalArgumentException
- if source
is null.com.fasterxml.jackson.core.JsonProcessingException
- if the generation of JSON
from the given Object
results in an error.ObjectMapper.writeValueAsString(Object)
,
newObjectMapper(Object)
@NonNull protected com.fasterxml.jackson.databind.ObjectMapper newObjectMapper(@NonNull java.lang.Object target)
ObjectMapper
class.ObjectMapper
class.ObjectMapper