-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
PlotlyJSONEncoder doesn't work with simplejson #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Possibly a duplicate of #197 |
Hmm, I've read through this but I don't think it's the same issue. Python/Anaconda/pip still work fine, and so does
|
If somebody want's to test it, here's a absolutely simple example which works when from flask import Flask, jsonify
import plotly
app = Flask(__name__)
@app.route('/')
def test():
return jsonify({})
if __name__ == "__main__":
app.debug = True
app.json_encoder = plotly.utils.PlotlyJSONEncoder
app.run(host="127.0.0.1", port=int("5000")) Update: Testet it also on an ubuntu pc without Anaconda, a plain python 3 - fails there as well as soon as simplejson is installed. |
Its more of a Flask issue than Plotly's. This simple snippet does not work when
Since PlotlyJSONEncoder is inherited from the native |
A workaround for this is to create a custom JSON Encoder which inherits both from
|
Building a web app using
flask
and thePlotlyJSONEncoder
doesn't work as soon assimplejson
is installed. Flask will automatically usesimplejson
then (and doesn't provide the option to use the inbuilt one), with whichPlotlyJSONEncoder
breakssimplejson
.E.g. my flask code
works fine until
simplejson
is installed, then it throws type errors:Where
tuple_as_array
is just an example, if I delete this one it will throw the same with all other json keywords (use_decimal, allow_nan, etc... ).Since simplejson is the de facto standard and it's pretty hard to make sure that a package is not installed, I would assume that the best way would be to adopt the Plotly encoder to work with simplejson as well.
The installed versions are up to date according to Anaconda.
The text was updated successfully, but these errors were encountered: