code: def json_serializer(obj):
      if isinstance(obj, datetime.date):
          return obj.isoformat()
      elif isinstance(obj, decimal.Decimal):
          return str(obj)
      raise TypeError("Unexpected " + obj.__class__.__name__)
  
imports: import datetime
  import decimal
  import difflib
  import json
  import os
  import traceback
  from collections.abc import Iterable
  from typing import Any
label_desc: Use image node_id 2 for calling a global function with example usage: json_serializer(obj) and returns: obj, str