flask-mongoengine icon indicating copy to clipboard operation
flask-mongoengine copied to clipboard

Flask2.3.X JSONEncoder deprecated

Open uamrws opened this issue 2 years ago • 7 comments

In Flask2.3.X, flask.json module deprecated JSONEncoder class, override_json_encoder is not working now. It will raise ImportError: cannot import name 'JSONEncoder' from 'flask.json'

uamrws avatar Apr 28 '23 09:04 uamrws

in the meantime, pinning flask == 2.2.5 helps.

jrypel avatar May 07 '23 22:05 jrypel

Yeap, can confirm the same problem.

sskender avatar May 08 '23 14:05 sskender

I think that this could be helpful

https://github.com/MongoEngine/flask-mongoengine/pull/537

EDIT: This fork can be helpful https://pypi.org/project/flask-mongoengine-3/

idoshr avatar May 19 '23 16:05 idoshr

json_encoder and json_decoder attributes on app and blueprint, and the corresponding json.JSONEncoder and JSONDecoder classes, are removed from Flask version 2.3.0.

So, it shows JSONEncoder = json.JSONEncoder AttributeError: module 'flask.json' has no attribute 'JSONEncoder'

For more refer: https://flask.palletsprojects.com/en/2.3.x/changes/#version-2-3-0

iammustafatz avatar Jun 01 '23 17:06 iammustafatz

#537

ruben-sprengel avatar Oct 03 '23 22:10 ruben-sprengel

downgrading to flask==2.2.5 worked for me! No longer getting this error

rohank0510 avatar Oct 20 '23 09:10 rohank0510

Is this a bug that will be fixed or are we to use @idoshr fork going forward. I think downgrading isn't the solution.

Audiosutras avatar Mar 30 '24 06:03 Audiosutras