code: def json_encoder_default(obj):
      
      if isinstance(obj, numbers.Integral) and (obj < min_safe_integer or obj > max_safe_integer):
          return str(obj)
      if isinstance(obj, np.integer):
          return str(obj)
      elif isinstance(obj, np.floating):
          return float(obj)
      elif isinstance(obj, np.ndarray):
          return list(obj)
      elif isinstance(obj, (set, frozenset)):
          return list(obj)
      raise TypeError
docs: JSON encoder function that handles some numpy types.