Python print and json.dumps changes float value
Solution 1:
This doesn't seem to be the normal behavior of json.dumps()
. For that reason, the best thing to do here is to ensure that everything is working correctly and reinstall any packages or modules that are causing the problem. Specifically, try reinstalling the base Python interpreter and see what happens with print(json.dumps(2341.0))
and other similar expressions. Additionally, if all else fails, you can always use a third-party library, like orjson.