Skip to content

Commit 35fdce0

Browse files
authored
Revert "Improve clarity in JSON loader documentation" (#758)
Reverts #742
1 parent ecfbd7c commit 35fdce0

File tree

1 file changed

+28
-27
lines changed
  • build/oss/javascript/integrations/document_loaders/file_loaders

1 file changed

+28
-27
lines changed

build/oss/javascript/integrations/document_loaders/file_loaders/json.mdx

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ The JSON loader use [JSON pointer](https://github.com/janl/node-jsonpointer) to
66

77
### No JSON pointer example
88

9-
The most simple way of using it is to specify no JSON pointer.
9+
The most simple way of using it, is to specify no JSON pointer.
1010
The loader will load all strings it finds in the JSON object.
1111

1212
Example JSON file:
1313

1414
```json
1515
{
16-
"texts": ["This is a sentence.", "This is another sentence."],
17-
"nestedTexts": {
18-
"one": "This is a sentence nested in an object.",
19-
"two": "This is another sentence nested in an object."
20-
}
16+
"texts": ["This is a sentence.", "This is another sentence."]
2117
}
2218
```
2319

@@ -32,28 +28,28 @@ const docs = await loader.load();
3228
/*
3329
[
3430
Document {
35-
pageContent: 'This is a sentence.',
36-
metadata: { source: 'example.json', line: 1 }
37-
},
38-
Document {
39-
pageContent: 'This is another sentence.',
40-
metadata: { source: 'example.json', line: 2 }
31+
"metadata": {
32+
"blobType": "application/json",
33+
"line": 1,
34+
"source": "blob",
35+
},
36+
"pageContent": "This is a sentence.",
4137
},
4238
Document {
43-
pageContent: 'This is a sentence nested in an object.',
44-
metadata: { source: 'example.json', line: 3 }
39+
"metadata": {
40+
"blobType": "application/json",
41+
"line": 2,
42+
"source": "blob",
43+
},
44+
"pageContent": "This is another sentence.",
4545
},
46-
Document {
47-
pageContent: 'This is another sentence nested in an object.',
48-
metadata: { source: 'example.json', line: 4 }
49-
}
5046
]
5147
*/
5248
```
5349

5450
### Using JSON pointer example
5551

56-
You can choose which keys in your JSON object you want to extract strings from.
52+
You can do a more advanced scenario by choosing which keys in your JSON object you want to extract string from.
5753

5854
In this example, we want to only extract information from "from" and "surname" entries.
5955

@@ -90,16 +86,21 @@ const docs = await loader.load();
9086
/*
9187
[
9288
Document {
93-
pageContent: 'LinkedIn Job',
94-
metadata: { source: 'example.json', line: 1 }
89+
"metadata": {
90+
"blobType": "application/json",
91+
"line": 1,
92+
"source": "blob",
93+
},
94+
"pageContent": "BD 2023 SUMMER",
9595
},
9696
Document {
97-
pageContent: 'LinkedIn Job2',
98-
metadata: { source: 'example.json', line: 2 }
97+
"metadata": {
98+
"blobType": "application/json",
99+
"line": 2,
100+
"source": "blob",
101+
},
102+
"pageContent": "LinkedIn Job",
99103
},
100-
Document {
101-
pageContent: 'bob',
102-
metadata: { source: 'example.json', line: 3 }
103-
}
104+
...
104105
]
105106
```

0 commit comments

Comments
 (0)