MCPcopy Create free account
hub / github.com/dagger/dagger / _safe_json_dumps

Function _safe_json_dumps

sdk/python/src/dagger/mod/_exceptions.py:182–188  ·  view source on GitHub ↗

Safely serialize value to JSON, falling back to repr() if not serializable.

(value: Any)

Source from the content-addressed store, hash-verified

180
181
182def _safe_json_dumps(value: Any) -> str:
183 """Safely serialize value to JSON, falling back to repr() if not serializable."""
184 try:
185 return json.dumps(value)
186 except (TypeError, ValueError):
187 # Fall back to string representation for non-serializable values
188 return json.dumps(repr(value))

Callers 1

record_exceptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected