Serialize
dumps ¶
Serialize object to string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
o | Any | the object to serialize | required |
use_decimal | bool | use decimal.Decimal for numbers. Defaults to True. | True |
**json_kwargs | other arguments passed to json.dumps | {} |
Returns:
Name | Type | Description |
---|---|---|
str | str | the serialized object as a string |
Source code in src/bloqade/serialize.py
load ¶
Load object from file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fp | Union[TextIO, str] | the file path or file object | required |
use_decimal | bool | use decimal.Decimal for numbers. Defaults to True. | True |
**json_kwargs | other arguments passed to json.load | {} |
Returns:
Name | Type | Description |
---|---|---|
Any | the deserialized object |
Source code in src/bloqade/serialize.py
loads ¶
Load object from string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s | str | the string to load | required |
use_decimal | bool | use decimal.Decimal for numbers. Defaults to True. | True |
**json_kwargs | other arguments passed to json.loads | {} |
Returns:
Name | Type | Description |
---|---|---|
Any | the deserialized object |
Source code in src/bloqade/serialize.py
save ¶
Serialize object to file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
o | Any | the object to serialize | required |
fp | Union[TextIO, str] | the file path or file object | required |
use_decimal | bool | use decimal.Decimal for numbers. Defaults to True. | True |
**json_kwargs | other arguments passed to json.dump | {} |
Returns:
Type | Description |
---|---|
None | None |