from __future__ import annotations import json from typing import Any def parse_json_text(value: Any, default: Any = None) -> Any: if default is None: default = {} if value is None or value == "": return default if isinstance(value, dict): return value try: return json.loads(value) except (TypeError, json.JSONDecodeError): return default