Toml
π€ AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
provide.foundation.serialization.toml
¶
Functions¶
toml_dumps
¶
Serialize dictionary to TOML string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
dict[str, Any]
|
Dictionary to serialize (TOML requires dict at top level) |
required |
Returns:
| Type | Description |
|---|---|
str
|
TOML string representation |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If object cannot be serialized |
ImportError
|
If tomli-w is not installed |
Example
toml_dumps({"key": "value"}) 'key = "value"\n'
Source code in provide/foundation/serialization/toml.py
toml_loads
¶
Deserialize TOML string to Python dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
TOML string to deserialize |
required |
use_cache
|
bool
|
Whether to use caching for this operation |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Deserialized Python dictionary |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If string is not valid TOML |
Example
toml_loads('key = "value"')