Class JacksonJsonHandler
java.lang.Object
com.caplin.datasource.messaging.json.JacksonJsonHandler
- All Implemented Interfaces:
JsonHandler<com.fasterxml.jackson.databind.JsonNode>
public class JacksonJsonHandler
extends Object
implements JsonHandler<com.fasterxml.jackson.databind.JsonNode>
-
Constructor Summary
ConstructorsConstructorDescriptionJacksonJsonHandler(Logger logger) JacksonJsonHandler(Logger logger, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodediff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target) Creates a JSON patch of the difference between two JSON tree representationsformat(com.fasterxml.jackson.databind.JsonNode jsonNode) Formats a JSON tree representation of an object to a JSON String.com.fasterxml.jackson.databind.JsonNodeParses a JSON text into a JSON tree representation used by the underlying JSON library.com.fasterxml.jackson.databind.JsonNodepatch(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode diff) Updates a JSON tree representation with a JSON patchcom.fasterxml.jackson.databind.JsonNodetoJsonTree(Object userObject) Serializes a plain Java object (POJO) to a JSON tree representation used by the underlying JSON library.Deserializes a JSON tree representation to a plain Java object
-
Constructor Details
-
JacksonJsonHandler
-
JacksonJsonHandler
-
JacksonJsonHandler
public JacksonJsonHandler()
-
-
Method Details
-
toJsonTree
Description copied from interface:JsonHandlerSerializes a plain Java object (POJO) to a JSON tree representation used by the underlying JSON library.- Specified by:
toJsonTreein interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>- Parameters:
userObject- a plain Java object- Returns:
- a JSON tree representation of the object
-
toObject
public Object toObject(com.fasterxml.jackson.databind.JsonNode jsonNode, Class userType) throws Exception Description copied from interface:JsonHandlerDeserializes a JSON tree representation to a plain Java object- Specified by:
toObjectin interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>- Parameters:
jsonNode- a JSON tree representation of the objectuserType- the type of the object to deserialize into- Returns:
- a new object of type userType
- Throws:
Exception- if deserialization fails
-
parse
Description copied from interface:JsonHandlerParses a JSON text into a JSON tree representation used by the underlying JSON library.- Specified by:
parsein interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>- Parameters:
jsonText- the JSON text to parse- Returns:
- a JSON tree representation of the JSON text
- Throws:
Exception- if the parsing fails
-
format
Description copied from interface:JsonHandlerFormats a JSON tree representation of an object to a JSON String.- Specified by:
formatin interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>- Parameters:
jsonNode- a JSON tree representation of an object- Returns:
- the JSON String
- Throws:
Exception- if formatting fails
-
diff
public com.fasterxml.jackson.databind.JsonNode diff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target) Description copied from interface:JsonHandlerCreates a JSON patch of the difference between two JSON tree representations- Specified by:
diffin interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>- Parameters:
source- a JSON tree representation of the source objecttarget- a JSON tree representation of the target object- Returns:
- a JSON tree representation of the JSON patch needed to patch source to create target.
-
patch
public com.fasterxml.jackson.databind.JsonNode patch(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode diff) throws Exception Description copied from interface:JsonHandlerUpdates a JSON tree representation with a JSON patch- Specified by:
patchin interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>- Parameters:
source- a JSON tree representation of the source objectdiff- a JSON tree representation of the JSON patch- Returns:
- the updated, patched object
- Throws:
Exception- if the patch fails
-