Skip to main content

JSON

Simple JSON file-based storage for development.

Quick Start

File Location

By default, JSON files are stored in:
  • ~/.praisonai/memory/ for memory data
  • ~/.praisonai/sessions/ for session data

When to Use

✅ Good for:
  • Local development
  • Testing
  • Quick prototyping
❌ Not recommended for:
  • Production deployments
  • Multi-user applications
  • Large datasets

Storage Backend (Advanced)

For training data, sessions, and general persistence, use the FileBackend:
BaseJSONStore.save() writes atomically: on success the staging .tmp is renamed over the real file; on serialization or encoding failure the original error propagates, the previous store is left intact, and the staging file is cleaned up. See Thread Safety → BaseJSONStore atomic save.
TrainingStorage is a context manager. FileBackend holds no open connection, so .close() is a safe no-op here — but using with keeps the pattern identical to the SQLite and Redis backends, where closing releases a file or network handle (essential on Windows and for long-running processes).
FileBackend.load() returns None on corrupted files (invalid UTF-8, malformed JSON, unreadable) and leaves the bytes untouched on disk. The same instance then refuses an ordinary save() on that key until you call backend.delete(key), the source is removed, or a subsequent load() succeeds — so a transient-looking fallback never silently overwrites forensic evidence. See Error Handling and Save-side guard for details.

CLI Usage

See Storage Backends for more details.