Interface JsonObjectReader<T>
- Type Parameters:
T
- type of the target object
- All Known Implementing Classes:
GsonJsonObjectReader
,JacksonJsonObjectReader
public interface JsonObjectReader<T>
Strategy interface for Json readers. Implementations are expected to use a streaming
API in order to read Json objects one at a time.
- Since:
- 4.1
- Author:
- Mahmoud Ben Hassine, Jimmy Praet
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Close the input resource.default void
jumpToItem
(int itemIndex) Move to the given item index.default void
open
(org.springframework.core.io.Resource resource) Open the Json resource for reading.read()
Read the next object in the Json resource if any.
-
Method Details
-
open
Open the Json resource for reading.- Parameters:
resource
- the input resource- Throws:
Exception
- if unable to open the resource
-
read
Read the next object in the Json resource if any.- Returns:
- the next object or
null
if the resource is exhausted - Throws:
Exception
- if unable to read the next object
-
close
Close the input resource.- Throws:
Exception
- if unable to close the input resource
-
jumpToItem
Move to the given item index. Implementations should override this method if there is a more efficient way of moving to given index than re-reading the input usingread()
.- Parameters:
itemIndex
- index of item (0 based) to jump to.- Throws:
Exception
- Allows implementations to throw checked exceptions for interpretation by the framework- Since:
- 5.2
-