public class Jackson2ResourceReader extends Object implements ResourceReader
ResourceReader
using Jackson to read JSON into objects.ResourceReader.Type
Constructor and Description |
---|
Jackson2ResourceReader()
Creates a new
Jackson2ResourceReader . |
Jackson2ResourceReader(com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new
Jackson2ResourceReader using the given ObjectMapper . |
Modifier and Type | Method and Description |
---|---|
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.
|
public Jackson2ResourceReader()
Jackson2ResourceReader
.public Jackson2ResourceReader(@Nullable com.fasterxml.jackson.databind.ObjectMapper mapper)
Jackson2ResourceReader
using the given ObjectMapper
.mapper
- public void setTypeKey(@Nullable String typeKey)
DEFAULT_TYPE_KEY
.typeKey
- public Object readFrom(Resource resource, @Nullable ClassLoader classLoader) throws Exception
ResourceReader
Collection
of target objects from the given Resource
.readFrom
in interface ResourceReader
resource
- must not be null.classLoader
- can be null.Collection
of target objects if resource contains multiple ones of single on. Never
null.Exception
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.