Class Jackson2ResourceReader

java.lang.Object
org.springframework.data.repository.init.Jackson2ResourceReader
All Implemented Interfaces:
ResourceReader

public class Jackson2ResourceReader extends Object implements ResourceReader
A ResourceReader using Jackson to read JSON into objects.
Since:
1.6
Author:
Oliver Gierke, Christoph Strobl, Mark Paluch, Johannes Englmeier
  • Constructor Details

    • Jackson2ResourceReader

      public Jackson2ResourceReader()
      Creates a new Jackson2ResourceReader.
    • Jackson2ResourceReader

      public Jackson2ResourceReader(@Nullable com.fasterxml.jackson.databind.ObjectMapper mapper)
      Creates a new Jackson2ResourceReader using the given ObjectMapper.
      Parameters:
      mapper -
  • Method Details

    • setTypeKey

      public void setTypeKey(@Nullable String typeKey)
      Configures the JSON document's key to lookup the type to instantiate the object. Defaults to DEFAULT_TYPE_KEY.
      Parameters:
      typeKey -
    • readFrom

      public Object readFrom(org.springframework.core.io.Resource resource, @Nullable ClassLoader classLoader) throws Exception
      Description copied from interface: ResourceReader
      Reads a single or Collection of target objects from the given Resource.
      Specified by:
      readFrom in interface ResourceReader
      Parameters:
      resource - must not be null.
      classLoader - can be null.
      Returns:
      Collection of target objects if resource contains multiple ones of single on. Never null.
      Throws:
      Exception