JSON Reader
Convert JSON files into knowledge base documents with JSONReader.
JSONReader creates one source document for a top-level object or each item in a top-level array, then applies fixed-size chunking.
import json
from pathlib import Path
from agno.knowledge.reader.json_reader import JSONReader
reader = JSONReader()
json_path = Path("tmp/test.json")
json_path.parent.mkdir(parents=True, exist_ok=True)
json_path.write_text(
json.dumps([{"name": "Jordan"}, {"name": "Taylor"}]),
encoding="utf-8",
)
documents = reader.read(json_path)
for document in documents:
print(document.meta_data["page"], document.content)Run the Reader
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agnoRun the script
python json_reader.pyReader Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
chunking_strategy | Optional[ChunkingStrategy] | FixedSizeChunking() | Strategy used to chunk documents |
JSONReader also accepts the base Reader constructor parameters.
Use a top-level object or array. In the current reader, number, boolean, and null roots raise a TypeError, and a string root splits into one document per character.
JSONReader.async_read() runs the synchronous reader in a worker thread.
Next Steps
| Task | Guide |
|---|---|
| Configure fixed-size chunking | Fixed-Size Chunking |
| Inspect the complete API | JSON Reader Reference |
| Compare available readers | Readers Overview |