Class Jackson2ResourceReader
java.lang.Object
org.springframework.data.repository.init.Jackson2ResourceReader
- All Implemented Interfaces:
ResourceReader
A
ResourceReader
using Jackson to read JSON into objects.- Since:
- 1.6
- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch, Johannes Englmeier
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.repository.init.ResourceReader
ResourceReader.Type
-
Constructor Summary
ConstructorDescriptionCreates a newJackson2ResourceReader
.Jackson2ResourceReader
(com.fasterxml.jackson.databind.ObjectMapper mapper) Creates a newJackson2ResourceReader
using the givenObjectMapper
. -
Method Summary
Modifier and TypeMethodDescriptionreadFrom
(Resource resource, ClassLoader classLoader) Reads a single orCollection
of target objects from the givenResource
.void
setTypeKey
(String typeKey) Configures the JSON document's key to lookup the type to instantiate the object.
-
Constructor Details
-
Jackson2ResourceReader
public Jackson2ResourceReader()Creates a newJackson2ResourceReader
. -
Jackson2ResourceReader
Creates a newJackson2ResourceReader
using the givenObjectMapper
.- Parameters:
mapper
-
-
-
Method Details
-
setTypeKey
Configures the JSON document's key to lookup the type to instantiate the object. Defaults toDEFAULT_TYPE_KEY
.- Parameters:
typeKey
-
-
readFrom
Description copied from interface:ResourceReader
Reads a single orCollection
of target objects from the givenResource
.- Specified by:
readFrom
in interfaceResourceReader
- 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
-