strands.types.json_dict
JSON serializable dictionary utilities.
JSONSerializableDict
Section titled “JSONSerializableDict”class JSONSerializableDict()Defined in: src/strands/types/json_dict.py:9
A key-value store with JSON serialization validation.
Provides a dict-like interface with automatic validation that all values are JSON serializable on assignment.
__init__
Section titled “__init__”def __init__(initial_state: dict[str, Any] | None = None)Defined in: src/strands/types/json_dict.py:16
Initialize JSONSerializableDict.
def set(key: str, value: Any) -> NoneDefined in: src/strands/types/json_dict.py:28
Set a value in the store.
Arguments:
key- The key to store the value undervalue- The value to store (must be JSON serializable)
Raises:
ValueError- If key is invalid, or if value is not JSON serializable
def get(key: str | None = None) -> AnyDefined in: src/strands/types/json_dict.py:45
Get a value or entire data.
Arguments:
key- The key to retrieve (if None, returns entire data dict)
Returns:
The stored value, entire data dict, or None if not found
delete
Section titled “delete”def delete(key: str) -> NoneDefined in: src/strands/types/json_dict.py:59
Delete a specific key from the store.
Arguments:
key- The key to delete
__getstate__
Section titled “__getstate__”def __getstate__() -> dict[str, Any]Defined in: src/strands/types/json_dict.py:83
Exclude the lock so the store stays picklable and deep-copyable.
__setstate__
Section titled “__setstate__”def __setstate__(state: dict[str, Any]) -> NoneDefined in: src/strands/types/json_dict.py:88
Restore the store with a fresh lock.