Skip to content

[From flask-restplus #589] Stop using failing ujson as default serializer #166

@Anogio

Description

@Anogio

Flask-restx uses ujson for serialization by default, falling back to normal json if unavailable.
As has been mentioned before ujson is quite flawed, with some people reporting rounding errors.

Additionally, ujson.dumps does not take the default argument, which allows one to pass any custom method as the serializer. Since my project uses some custom serialization, I have been forced to fork flask-restx and just remove the ujson import line...

You could add an option to choose which lib to use, or completely remove ujson from there. I think it is bad practice to have to maintain the code for two lbraries with different APIs.
An alternative could be to make ujson an optional dependency and not list it in the package dependencies, but keep the current imports as they are. As a result, anyone wanting to use ujson can install it and it will take over transparently.

Original issue: https://github.com/noirbizarre/flask-restplus/issues/589

I would gladly make the PR if you are happy with one of these solutions

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions