ds_resource_plugin_py_lib.libs.utils.json_default¶
File: json_default.py
Region: ds_resource_plugin_py_lib/libs/utils
Description¶
JSON serialization helpers for values that are not natively JSON-encodable.
Example
from datetime import datetime
import json
from ds_resource_plugin_py_lib.libs.utils.json_default import json_default
payload = json.dumps({"created_at": datetime(2024, 3, 15, 10, 30)}, default=json_default)
Functions¶
|
|
Module Contents¶
- ds_resource_plugin_py_lib.libs.utils.json_default.json_default(value: Any) Any[source]¶
defaultcallback forjson.dumps().Maps common Python types (for example
datetime) to JSON-serializable values. Scalar-like objects with a callable.item()(for example numpy scalars) are unwrapped before encoding. Unknown types raiseTypeError, matching stdlib behavior.bytesandbytearrayare intentionally not converted: JSON has no binary type, and decoding bytes as text would silently change the data.