text: from flask.json import JSONEncoder
  from datetime import datetime
  
  class CustomJSONEncoder(JSONEncoder):
  
      def default(self, obj):
          try:
              if isinstance(obj, datetime):
                  return obj.isoformat()
              iterable = iter(obj)
          except TypeError:
              pass
          else:
              return list(iterable)
          return JSONEncoder.default(self, obj)
  