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
ConstructorsConstructorDescriptionCreates a newJackson2ResourceReader.Jackson2ResourceReader(com.fasterxml.jackson.databind.ObjectMapper mapper) Creates a newJackson2ResourceReaderusing the givenObjectMapper. -
Method Summary
Modifier and TypeMethodDescriptionreadFrom(Resource resource, ClassLoader classLoader) Reads a single orCollectionof target objects from the givenResource.voidsetTypeKey(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 newJackson2ResourceReaderusing 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:ResourceReaderReads a single orCollectionof target objects from the givenResource.- Specified by:
readFromin interfaceResourceReader- Parameters:
resource- must not be null.classLoader- can be null.- Returns:
Collectionof target objects if resource contains multiple ones of single on. Never null.- Throws:
Exception
-