Skip to content

Flask2.3.X JSONEncoder deprecated #522

Open

Description

@uamrws

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'

Activity

  1. jrypel commented on May 7, 2023

    @jrypel

    in the meantime, pinning flask == 2.2.5 helps.

  2. sskender commented on May 8, 2023

    @sskender

    Yeap, can confirm the same problem.

  3. idoshr commented on May 19, 2023

    @idoshr
    Contributor

    I think that this could be helpful

    #537

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

  4. iammustafatz commented on Jun 1, 2023

    @iammustafatz

    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

  5. added a commit that references this issue on Sep 18, 2023
  6. ruben-sprengel commented on Oct 3, 2023

    @ruben-sprengel
  7. rohank0510 commented on Oct 20, 2023

    @rohank0510

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

  8. Audiosutras commented on Mar 30, 2024

    @Audiosutras

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions