code: def _ensure_serialization(o: object) -> Union[str, List[Any]]:
      """A repr function for json.dumps default arg, which tries to serialize sets as lists"""
      if isinstance(o, set):
          return list(o)
      return repr(o)
  
file_path: streamlit/lib/streamlit/elements/json.py
imports: import json
  from typing import TYPE_CHECKING, Any, List, Union, cast
  from streamlit.proto.Json_pb2 import Json
  from streamlit.runtime.metrics_util import gather_metrics
  from streamlit.runtime.state import QueryParamsProxy, SessionStateProxy
  from streamlit.user_info import UserInfoProxy
label_desc: Use image node_id 1 for calling a global function with example usage: _ensure_serialization(o) and returns: repr, list