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 Type
    Method
    Description
    default void
    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 the next object in the Json resource if any.
  • Method Details

    • open

      default void open(org.springframework.core.io.Resource resource) throws Exception
      Open the Json resource for reading.
      Parameters:
      resource - the input resource
      Throws:
      Exception - if unable to open the resource
    • read

      @Nullable T read() throws Exception
      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

      default void close() throws Exception
      Close the input resource.
      Throws:
      Exception - if unable to close the input resource
    • jumpToItem

      default void jumpToItem(int itemIndex) throws Exception
      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 using read().
      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