SandboxState provides JSON serialization for capability sets. Use it to persist sandbox configurations, pass them across process boundaries, or store them in configuration files.
Creating State
from_caps
CapabilitySet
required
The capability set to snapshot.
SandboxState instance.
from_json
str
required
JSON string to parse.
SandboxState instance.
Raises:
ValueError- Invalid JSON format
Methods
to_json
to_caps
CapabilitySet instance.
Raises:
FileNotFoundError- A path in the state no longer exists
Properties
net_blocked
True if network access is blocked in this state.
JSON Format
The serialized JSON has this structure:Use Cases
Persist Configuration
Save sandbox configuration to a file:Pass Across Processes
Transfer sandbox configuration via environment variable or IPC:Configuration Validation
Load and validate a configuration file:Round-Trip Example
Complete example showing serialization round-trip:Related
- CapabilitySet - The capability set being serialized
- apply() - Apply restored capabilities