Package com.alibaba.cloud.ai.document
Class JsonDocumentParser
java.lang.Object
com.alibaba.cloud.ai.document.JsonDocumentParser
- All Implemented Interfaces:
DocumentParser
- Since:
- 2024-12-08 21:13
- Author:
- HeYQ
-
Constructor Summary
ConstructorsConstructorDescriptionJsonDocumentParser(String... jsonKeysToUse) JsonDocumentParser(org.springframework.ai.reader.JsonMetadataGenerator jsonMetadataGenerator, String... jsonKeysToUse) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.springframework.ai.document.Document>get(com.fasterxml.jackson.databind.JsonNode rootNode) List<org.springframework.ai.document.Document>get(String pointer, InputStream inputStream) Retrieves documents from the JSON resource using a JSON Pointer.List<org.springframework.ai.document.Document>parse(InputStream inputStream) Parses a givenInputStreaminto aDocument.
-
Constructor Details
-
JsonDocumentParser
-
JsonDocumentParser
public JsonDocumentParser(org.springframework.ai.reader.JsonMetadataGenerator jsonMetadataGenerator, String... jsonKeysToUse)
-
-
Method Details
-
parse
Description copied from interface:DocumentParserParses a givenInputStreaminto aDocument. The specific implementation of this method will depend on the type of the document being parsed.Note: This method does not close the provided
InputStream- it is the caller's responsibility to manage the lifecycle of the stream.- Specified by:
parsein interfaceDocumentParser- Parameters:
inputStream- TheInputStreamthat contains the content of theDocument.- Returns:
- The parsed
Document.
-
get
protected List<org.springframework.ai.document.Document> get(com.fasterxml.jackson.databind.JsonNode rootNode) -
get
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
-