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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfinal CouchbaseStorabledecode(String source, CouchbaseStorable target) Decode a JSON string into theCouchbaseStorablestructure.<T> TdecodeFragment(String source, Class<T> target) Decodes an ad-hoc JSON object into a corresponding "case" class.final Stringencode(CouchbaseStorable source) Encode aCouchbaseStorableto a JSON string.voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Constructor Details
-
JacksonTranslationService
public JacksonTranslationService()
-
-
Method Details
-
encode
Encode aCouchbaseStorableto a JSON string.- Specified by:
encodein interfaceTranslationService- Parameters:
source- the source document to encode.- Returns:
- the encoded JSON String.
-
decode
Decode a JSON string into theCouchbaseStorablestructure.- Specified by:
decodein interfaceTranslationService- Parameters:
source- the source formatted document.target- the target of the populated data.- Returns:
- the decoded structure.
-
decodeFragment
Description copied from interface:TranslationServiceDecodes an ad-hoc JSON object into a corresponding "case" class.- Specified by:
decodeFragmentin 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:
afterPropertiesSetin interfaceInitializingBean
-