org.springframework.data.repository.init

## 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

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.springframework.data.repository.init.ResourceReader

`ResourceReader.Type`

### Constructor Summary

Constructors
Constructor and Description
`Jackson2ResourceReader()` Creates a new `Jackson2ResourceReader`.
`Jackson2ResourceReader(com.fasterxml.jackson.databind.ObjectMapper mapper)` Creates a new `Jackson2ResourceReader` using the given `ObjectMapper`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Object` `readFrom(Resource resource, ClassLoader classLoader)` Reads a single or `Collection` of target objects from the given `Resource`.
`void` `setTypeKey(String typeKey)` Configures the JSON document's key to lookup the type to instantiate the object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### 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 Detail

#### 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(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`