Class JacksonJsonObjectUnmarshaller<T>

java.lang.Object
org.springframework.batch.infrastructure.item.json.JacksonJsonObjectUnmarshaller<T>
Type Parameters:
T - type of objects to unmarshal
All Implemented Interfaces:
JsonObjectUnmarshaller<T>

public class JacksonJsonObjectUnmarshaller<T> extends Object implements JsonObjectUnmarshaller<T>
A json object unmarshaller that uses Jackson 3 to unmarshal a json representation into an object.
Since:
6.1
Author:
Mahmoud Ben Hassine, Yanming Zhou
  • Constructor Details

    • JacksonJsonObjectUnmarshaller

      public JacksonJsonObjectUnmarshaller(Class<T> type)
      Create a new JacksonJsonObjectUnmarshaller with a default JsonMapper.
      Parameters:
      type - the target type
    • JacksonJsonObjectUnmarshaller

      public JacksonJsonObjectUnmarshaller(tools.jackson.core.type.TypeReference<T> type)
      Create a new JacksonJsonObjectUnmarshaller with a default JsonMapper. Use this constructor for parameterized target types, for example new TypeReference<Map<String, Object>>() {}.
      Parameters:
      type - the target type
    • JacksonJsonObjectUnmarshaller

      public JacksonJsonObjectUnmarshaller(tools.jackson.databind.json.JsonMapper jsonMapper, Class<T> type)
      Create a new JacksonJsonObjectUnmarshaller with the provided JsonMapper.
      Parameters:
      jsonMapper - the json mapper to use
      type - the target type
    • JacksonJsonObjectUnmarshaller

      public JacksonJsonObjectUnmarshaller(tools.jackson.databind.json.JsonMapper jsonMapper, tools.jackson.core.type.TypeReference<T> type)
      Create a new JacksonJsonObjectUnmarshaller with the provided JsonMapper. Use this constructor for parameterized target types, for example new TypeReference<Map<String, Object>>() {}.
      Parameters:
      jsonMapper - the json mapper to use
      type - the target type
  • Method Details

    • unmarshal

      public T unmarshal(String json)
      Unmarshal the provided json into an object of the target type.
      Specified by:
      unmarshal in interface JsonObjectUnmarshaller<T>
      Parameters:
      json - the json representation of the object
      Returns:
      the unmarshalled object
      Throws:
      ParseException - if the json cannot be unmarshalled