-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
jsonify doesn't accept a list #170
Comments
It's there for security reasons: http://flask.pocoo.org/docs/security/#json-security |
Can we have a way around this, perhaps a kwarg like I'm building a backend API with Flask and the data is public and unauthenticated, so I don't need to worry about security in this case. I respect Flask's decision to be secure by default, but it would be nice to have a way around it. |
I'm not sure what the point of the restriction is. Someone could easily just hit users/1 users/2 users/3 and such and get the JSON from each individually. All this does is stop jsonify from being useful for lists. |
Top level arrays are generally considered unsafe in json responses. Armin wrote an article about it once I believe: http://flask.pocoo.org/docs/security/#json-security It's really not difficult to just do |
If you're insistent on doing this, make your own response object, import the json module, dump your list as a string and fill the response object accordingly. |
I see. So just top-level have the issues. Fair enough. Thanks for the post apiguy |
Please continue discussion at #248 |
I was suprised to find that jsonify(['hello', 'world']) will raise a TypeError even though
is valid json.
I think there should be a check to see if the first argument is a list instance and just do a json dump of the first argument if it is or something like that.
The text was updated successfully, but these errors were encountered: