Class JacksonJsonHandler
- java.lang.Object
-
- com.caplin.datasource.messaging.json.JacksonJsonHandler
-
- All Implemented Interfaces:
JsonHandler<com.fasterxml.jackson.databind.JsonNode>
public class JacksonJsonHandler extends java.lang.Object implements JsonHandler<com.fasterxml.jackson.databind.JsonNode>
-
-
Constructor Summary
Constructors Constructor Description JacksonJsonHandler()
JacksonJsonHandler(java.util.logging.Logger logger)
JacksonJsonHandler(java.util.logging.Logger logger, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.JsonNode
diff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target)
Creates a JSON patch of the difference between two JSON tree representationsjava.lang.String
format(com.fasterxml.jackson.databind.JsonNode jsonNode)
Formats a JSON tree representation of an object to a JSON String.com.fasterxml.jackson.databind.JsonNode
parse(java.lang.String jsonText)
Parses a JSON text into a JSON tree representation used by the underlying JSON library.com.fasterxml.jackson.databind.JsonNode
patch(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode diff)
Updates a JSON tree representation with a JSON patchcom.fasterxml.jackson.databind.JsonNode
toJsonTree(java.lang.Object userObject)
Serializes a plain Java object (POJO) to a JSON tree representation used by the underlying JSON library.java.lang.Object
toObject(com.fasterxml.jackson.databind.JsonNode jsonNode, java.lang.Class userType)
Deserializes a JSON tree representation to a plain Java object
-
-
-
Method Detail
-
toJsonTree
public com.fasterxml.jackson.databind.JsonNode toJsonTree(java.lang.Object userObject)
Description copied from interface:JsonHandler
Serializes a plain Java object (POJO) to a JSON tree representation used by the underlying JSON library.- Specified by:
toJsonTree
in interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>
- Parameters:
userObject
- a plain Java object- Returns:
- a JSON tree representation of the object
-
toObject
public java.lang.Object toObject(com.fasterxml.jackson.databind.JsonNode jsonNode, java.lang.Class userType) throws java.lang.Exception
Description copied from interface:JsonHandler
Deserializes a JSON tree representation to a plain Java object- Specified by:
toObject
in 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:
java.lang.Exception
- if deserialization fails
-
parse
public com.fasterxml.jackson.databind.JsonNode parse(java.lang.String jsonText) throws java.lang.Exception
Description copied from interface:JsonHandler
Parses a JSON text into a JSON tree representation used by the underlying JSON library.- Specified by:
parse
in interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>
- Parameters:
jsonText
- the JSON text to parse- Returns:
- a JSON tree representation of the JSON text
- Throws:
java.lang.Exception
- if the parsing fails
-
format
public java.lang.String format(com.fasterxml.jackson.databind.JsonNode jsonNode) throws java.lang.Exception
Description copied from interface:JsonHandler
Formats a JSON tree representation of an object to a JSON String.- Specified by:
format
in interfaceJsonHandler<com.fasterxml.jackson.databind.JsonNode>
- Parameters:
jsonNode
- a JSON tree representation of an object- Returns:
- the JSON String
- Throws:
java.lang.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:JsonHandler
Creates a JSON patch of the difference between two JSON tree representations- Specified by:
diff
in 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 java.lang.Exception
Description copied from interface:JsonHandler
Updates a JSON tree representation with a JSON patch- Specified by:
patch
in 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:
java.lang.Exception
- if the patch fails
-
-