Class JacksonObjectToJsonConverter
java.lang.Object
org.springframework.geode.data.json.converter.support.JacksonObjectToJsonConverter
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Object,
,String> ObjectToJsonConverter
- Direct Known Subclasses:
JSONFormatterPdxToJsonConverter
A
ObjectToJsonConverter
implementation using Jackson's ObjectMapper
to convert
from an Object
to a JSON String
.- Since:
- 1.3.0
- See Also:
-
JsonTypeInfo
JsonGenerator
ObjectMapper
MapperFeature
TypeDescriptor
ObjectToJsonConverter
PdxInstanceWrapper
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
convertObjectToJson
(Object source) protected com.fasterxml.jackson.databind.ObjectMapper
newObjectMapper
(Object target) Constructs a new instance of the JacksonObjectMapper
class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.convert.converter.Converter
andThen
-
Field Details
-
AT_TYPE_METADATA_PROPERTY_NAME
- See Also:
-
-
Constructor Details
-
JacksonObjectToJsonConverter
public JacksonObjectToJsonConverter()
-
-
Method Details
-
convert
- Specified by:
convert
in interfaceorg.springframework.core.convert.converter.Converter<Object,
String> - Parameters:
source
-Object
to convert intoJSON
.- Returns:
JSON
generated from the givenObject
using Jackson'sObjectMapper
.- Throws:
IllegalArgumentException
- ifsource
is null.org.springframework.core.convert.ConversionFailedException
- if aJsonProcessingException
is thrown or another error occurs while trying to convert the givenObject
toJSON
.- See Also:
-
ObjectMapper
convertObjectToJson(Object)
-
convertObjectToJson
@NonNull protected String convertObjectToJson(@NonNull Object source) throws com.fasterxml.jackson.core.JsonProcessingException - Parameters:
source
-Object
to convert toJSON
; must not be null.- Returns:
JSON
generated from the givenObject
.- Throws:
IllegalArgumentException
- ifsource
is null.com.fasterxml.jackson.core.JsonProcessingException
- if the generation ofJSON
from the givenObject
results in an error.- See Also:
-
ObjectMapper.writeValueAsString(Object)
newObjectMapper(Object)
-
newObjectMapper
@NonNull protected com.fasterxml.jackson.databind.ObjectMapper newObjectMapper(@NonNull Object target) Constructs a new instance of the JacksonObjectMapper
class.- Returns:
- a new instance of the Jackson
ObjectMapper
class. - See Also:
-
ObjectMapper
-