Class JacksonResourceReader
java.lang.Object
org.springframework.data.repository.init.JacksonResourceReader
- All Implemented Interfaces:
ResourceReader
A
ResourceReader
using Jackson to read JSON into objects.- Since:
- 4.0
- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch, Johannes Englmeier
-
Nested Class Summary
Nested classes/interfaces inherited from interface ResourceReader
ResourceReader.Type
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newJacksonResourceReader
.JacksonResourceReader
(tools.jackson.databind.ObjectMapper mapper) Creates a newJacksonResourceReader
using the givenObjectMapper
. -
Method Summary
Modifier and TypeMethodDescriptionreadFrom
(Resource resource, @Nullable ClassLoader classLoader) Reads a single orCollection
of target objects from the givenResource
.void
setTypeKey
(@Nullable String typeKey) Configures the JSON document's key to look up the type to instantiate the object.
-
Constructor Details
-
JacksonResourceReader
public JacksonResourceReader()Creates a newJacksonResourceReader
. -
JacksonResourceReader
public JacksonResourceReader(tools.jackson.databind.ObjectMapper mapper) Creates a newJacksonResourceReader
using the givenObjectMapper
.- Parameters:
mapper
-
-
-
Method Details
-
setTypeKey
Configures the JSON document's key to look up 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
-