python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.17k stars 337 forks source link

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

Open Anogio opened 4 years ago

Anogio commented 4 years ago

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

JishnuRamesh commented 3 years ago

@j5awry I can pick this up if no one has tried it yet

SkandaPrasad-S commented 1 year ago

Has this been completed already? I can pick this up if no one has

ReynanVv commented 3 months ago

This issue has been resolved; the error handling in the import ensures that ujson is optional.

Captura de Tela 2024-09-04 às 00 29 51