(value: Any)
| 13 | |
| 14 | |
| 15 | def serialize_json_value(value: Any) -> Any: |
| 16 | if isinstance(value, (str, int, float, bool)) or value is None: |
| 17 | return value |
| 18 | if isinstance(value, Mapping): |
| 19 | return {str(key): serialize_json_value(val) for key, val in value.items()} |
| 20 | if isinstance(value, Sequence) and not isinstance(value, (str, bytes, bytearray)): |
| 21 | return [serialize_json_value(item) for item in value] |
| 22 | if hasattr(value, "to_dict") and callable(value.to_dict): |
| 23 | return serialize_json_value(value.to_dict()) |
| 24 | if hasattr(value, "content"): |
| 25 | return serialize_json_value(value.content) |
| 26 | return str(value) |
| 27 | |
| 28 | |
| 29 | def _serialize_mapping(value: Any) -> dict[str, Any]: |
no test coverage detected