> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# JSONStorage

> File-based JSON storage for simple persistence

## Overview

`JSONStorage` provides a file-based JSON storage backend. Ideal for simple applications, prototyping, and scenarios where human-readable data files are preferred.

## Basic Usage

```python theme={null}
from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.json import JSONStorage

storage = JSONStorage(db_path="./memory_data")

memory = Memory(
    storage=storage,
    session_id="session_001",
    user_id="user_123",
    full_session_memory=True,
    summary_memory=True,
    user_analysis_memory=True,
    model="anthropic/claude-sonnet-4-5"
)

agent = Agent("anthropic/claude-sonnet-4-5", memory=memory)

result1 = agent.do(Task("My name is Bob"))
result2 = agent.do(Task("What's my name?"))
print(result2)  # "Your name is Bob"
```

## File Structure

```
memory_data/
├── upsonic_sessions.json
├── upsonic_user_memories.json
└── upsonic_knowledge.json   # created when used with KnowledgeBase
```

## Parameters

| Parameter           | Type          | Default                   | Description                                                              |
| ------------------- | ------------- | ------------------------- | ------------------------------------------------------------------------ |
| `db_path`           | `str \| None` | `"./upsonic_json_db"`     | Directory for JSON files                                                 |
| `session_table`     | `str \| None` | `"upsonic_sessions"`      | Session JSON file name (without .json)                                   |
| `user_memory_table` | `str \| None` | `"upsonic_user_memories"` | User memory JSON file name (without .json)                               |
| `knowledge_table`   | `str \| None` | `"upsonic_knowledge"`     | Knowledge registry JSON file name (without .json, used by KnowledgeBase) |
| `id`                | `str \| None` | auto-generated            | Storage instance ID                                                      |

## Storage Type

`JSONStorage` is a **synchronous** storage implementation using file-based JSON serialization.
