# 10. 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>

Copy

```
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)
```

Copy

```
[{'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']}] 
```

Copy

```
type(data[0])
```

Copy

```
dict
```

#### JSONLoader <a href="#jsonloader" id="jsonloader"></a>

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.

Copy

```
from langchain_community.document_loaders import JSONLoader

# JSONLoader generation
loader = JSONLoader(
    file_path="data/people.json",
    jq_schema=".[].phoneNumbers",
    text_content=False,
)

# load document
docs = loader.load()

# Output the results
pprint(docs)
```

Copy

```
[Document (metadata={'source':'/Users/teddy/Dev/github/langchain-master/07-DocumentLoader/data/people.json','seq_num': 1}, page_content=" [ '483-46 
 Document (metadata={'source':'/Users/teddy/Dev/github/langchain-master/07-DocumentLoader/data/people.json','seq_num': 2}, page_content=" [ '337-5721- 
 Document (metadata={'source':'/Users/teddy/Dev/github/langchain-master/07-DocumentLoader/data/people.json','seq_num': 3}, page_content=" [ '354-563-4 
... 
(meditation) 
... 
 Document (metadata={'source':'/Users/teddy/Dev/github/langchain-master/07-DocumentLoader/data/people.json','seq_num': 19}, page_content=" [ '290-8270 
 Document (metadata={'source':'/Users/teddy/Dev/github/langchain-master/07-DocumentLoader/data/people.json','seq_num': 20}, page_content=" [ '460-453 
```
