Skip to content

Commit

Permalink
refactor(doc-loaders): Use JsonPath.readValues in JsonLoader (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
f3ath authored and davidmigloz committed Nov 23, 2023
1 parent c24877c commit 3e15925
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/langchain/lib/src/documents/loaders/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ class JsonLoader extends BaseDocumentLoader {
final fileContent = await file.readAsString();
final jsonData = json.decode(fileContent);

for (final match in basePath.read(jsonData)) {
for (final value in basePath.readValues(jsonData)) {
final doc = Document(
pageContent: match.value.toString(),
metadata:
metadataBuilder?.call(match.value, fileMetadata) ?? fileMetadata,
pageContent: value.toString(),
metadata: metadataBuilder?.call(value, fileMetadata) ?? fileMetadata,
);
yield doc;
}
Expand Down

0 comments on commit 3e15925

Please sign in to comment.