code: def to_json(obj, simple=False, **json_kw) -> str:
      """Serialize to a JSON string."""
      cls = SimpleJSONEncoder if simple else CustomJSONEncoder
      return json.dumps(obj, cls=cls, **json_kw)
  
file_path: lit/lit_nlp/lib/serialize.py
imports: import json
  from types import MappingProxyType
  from typing import Any, cast, Optional
  from lit_nlp.api import dtypes
  from lit_nlp.api import types
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: to_json(obj, simple) and returns: json