Change JSONEncoder: use Python's json module instead of Flask

This commit is contained in:
Emmanuel Viennet 2023-04-04 12:14:05 +02:00
parent 1f2952e0d0
commit dd89e6fa9c

View File

@ -19,7 +19,8 @@ from flask import current_app, g, request
from flask import Flask from flask import Flask
from flask import abort, flash, has_request_context, jsonify from flask import abort, flash, has_request_context, jsonify
from flask import render_template from flask import render_template
from flask.json import JSONEncoder
# from flask.json import JSONEncoder
from flask.logging import default_handler from flask.logging import default_handler
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
@ -144,7 +145,7 @@ def handle_invalid_usage(error):
# JSON ENCODING # JSON ENCODING
class ScoDocJSONEncoder(JSONEncoder): class ScoDocJSONEncoder(json.JSONEncoder):
def default(self, o): # pylint: disable=E0202 def default(self, o): # pylint: disable=E0202
if isinstance(o, (datetime.date, datetime.datetime)): if isinstance(o, (datetime.date, datetime.datetime)):
return o.isoformat() return o.isoformat()