Skip to content

strands.types.json_dict

JSON serializable dictionary utilities.

class JSONSerializableDict()

Defined in: src/strands/types/json_dict.py:8

A key-value store with JSON serialization validation.

Provides a dict-like interface with automatic validation that all values are JSON serializable on assignment.

def __init__(initial_state: dict[str, Any] | None = None)

Defined in: src/strands/types/json_dict.py:15

Initialize JSONSerializableDict.

def set(key: str, value: Any) -> None

Defined in: src/strands/types/json_dict.py:25

Set a value in the store.

Arguments:

  • key - The key to store the value under
  • value - 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) -> Any

Defined in: src/strands/types/json_dict.py:40

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

def delete(key: str) -> None

Defined in: src/strands/types/json_dict.py:54

Delete a specific key from the store.

Arguments:

  • key - The key to delete