An ebook/comic library service and web client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
409 B

  1. from datetime import date
  2. import rfc3339
  3. from flask.json import JSONEncoder
  4. class CustomJSONEncoder(JSONEncoder):
  5. def default(self, obj):
  6. try:
  7. if isinstance(obj, date):
  8. return rfc3339.format(obj)
  9. iterable = iter(obj)
  10. except TypeError:
  11. pass
  12. else:
  13. return list(iterable)
  14. return JSONEncoder.default(self, obj)