Class JacksonTranslationService
java.lang.Object
org.springframework.data.couchbase.core.convert.translation.JacksonTranslationService
- All Implemented Interfaces:
InitializingBean
,TranslationService
public class JacksonTranslationService
extends Object
implements TranslationService, InitializingBean
A Jackson JSON Translator that implements the
TranslationService
contract.- Author:
- Michael Nitschinger, Simon Baslé, Anastasiia Smirnova, Mark Paluch
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
final CouchbaseStorable
decode
(String source, CouchbaseStorable target) Decode a JSON string into theCouchbaseStorable
structure.<T> T
decodeFragment
(String source, Class<T> target) Decodes an ad-hoc JSON object into a corresponding "case" class.final String
encode
(CouchbaseStorable source) Encode aCouchbaseStorable
to a JSON string.void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Constructor Details
-
JacksonTranslationService
public JacksonTranslationService()
-
-
Method Details
-
encode
Encode aCouchbaseStorable
to a JSON string.- Specified by:
encode
in interfaceTranslationService
- Parameters:
source
- the source document to encode.- Returns:
- the encoded JSON String.
-
decode
Decode a JSON string into theCouchbaseStorable
structure.- Specified by:
decode
in interfaceTranslationService
- Parameters:
source
- the source formatted document.target
- the target of the populated data.- Returns:
- the decoded structure.
-
decodeFragment
Description copied from interface:TranslationService
Decodes an ad-hoc JSON object into a corresponding "case" class.- Specified by:
decodeFragment
in interfaceTranslationService
- Type Parameters:
T
- the target class.- Parameters:
source
- the JSON for the ad-hoc JSON object (from a N1QL query for instance).target
- the target class information.- Returns:
- an ad-hoc instance of the decoded JSON into the corresponding "case" class.
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-