Serialize
dumps
dumps(
o: Any, use_decimal: bool = True, **json_kwargs
) -> str
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 .venv/lib/python3.12/site-packages/bloqade/analog/serialize.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
load
load(
fp: Union[TextIO, str],
use_decimal: bool = True,
**json_kwargs
)
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 .venv/lib/python3.12/site-packages/bloqade/analog/serialize.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
loads
loads(s: str, use_decimal: bool = True, **json_kwargs)
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 .venv/lib/python3.12/site-packages/bloqade/analog/serialize.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
save
save(
o: Any,
fp: Union[TextIO, str],
use_decimal=True,
**json_kwargs
) -> None
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 |
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/serialize.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |