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
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Close the input resource.
    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