Class JsonReader

java.lang.Object
org.springframework.ai.reader.JsonReader
All Implemented Interfaces:
Supplier<List<Document>>, DocumentReader

public class JsonReader extends Object implements DocumentReader
A class that reads JSON documents and converts them into a list of Document objects.
Since:
1.0.0
Author:
Mark Pollack, Christian Tzolov, rivkode rivkode
  • Constructor Details

    • JsonReader

      public JsonReader(org.springframework.core.io.Resource resource)
    • JsonReader

      public JsonReader(org.springframework.core.io.Resource resource, String... jsonKeysToUse)
    • JsonReader

      public JsonReader(org.springframework.core.io.Resource resource, JsonMetadataGenerator jsonMetadataGenerator, String... jsonKeysToUse)
  • Method Details

    • get

      public List<Document> get()
      Specified by:
      get in interface Supplier<List<Document>>
    • get

      protected List<Document> get(com.fasterxml.jackson.databind.JsonNode rootNode)
    • get

      public List<Document> get(String pointer)
      Retrieves documents from the JSON resource using a JSON Pointer.
      Parameters:
      pointer - A JSON Pointer string (RFC 6901) to locate the desired element
      Returns:
      A list of Documents parsed from the located JSON element
      Throws:
      RuntimeException - if the JSON cannot be parsed or the pointer is invalid