MCPcopy Create free account
hub / github.com/Dizzy-K/AutoPT / serialize_json_value

Function serialize_json_value

runner/result_schema.py:15–26  ·  view source on GitHub ↗
(value: Any)

Source from the content-addressed store, hash-verified

13
14
15def 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
29def _serialize_mapping(value: Any) -> dict[str, Any]:

Callers 4

runMethod · 0.85
_serialize_mappingFunction · 0.85
_serialize_listFunction · 0.85
normalize_task_detailsFunction · 0.85

Calls 1

to_dictMethod · 0.45

Tested by

no test coverage detected