10. JSON
JSON
.json Let's look at how to load files with extensions into loaders.
Note: https://python.langchain.com/docs/modules/data_connection/document_loaders/json
import json
from pathlib import Path
from pprint import pprint
file_path = "data/people.json"
data = json.loads(Path(file_path).read_text())
pprint(data)[{'address': {'city':'Seoul','street': '312 times','zipCode': '83795'},
'age': 31,
'carOwnership': True,
'hobbies': ['cooking','music listening','photo shooting'],
'isMarried': True,
'name':'boxy',
'phoneNumbers': ['483-4639-1933', '947-4179-7976']},
{'address': {'city':'Seoul','street': '877 times','zipCode': '36780'},
'age': 31,
'carOwnership': True,
'hobbies': ['travel','music appreciation','climbing'],
'isMarried': False,
'name':'singer',
'phoneNumbers': ['337-5721-3227', '387-3768-9586']},
...
(meditation)
...
{'address': {'city':'Seoul','street': '940th Street','zipCode': '60335'},
'age': 52,
'carOwnership': True,
'hobbies': ['cooking','photo shooting','climbing'],
'isMarried': True,
'name':'Chief Yoon',
'phoneNumbers': ['290-8270-9786', '483-1765-4028']},
{'address': {'city':'Seoul','street': '289 times','zipCode': '59793'},
'age': 18,
'carOwnership': True,
'hobbies': ['Travel','Cooking','Watch the Movie'],
'isMarried': True,
'name':'Minister',
'phoneNumbers': ['460-4533-7245', '344-2344-7362']}] JSONLoader
Assuming you want to extract the value below the content field within the message key of the JSON data, you can easily do it through JSONLoader as shown below.
Last updated