Skip to content
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

Fixed json.jsonify #790

Closed
wants to merge 2 commits into from
Closed

Conversation

devilicecream
Copy link

Modified jsonify to allow passing the same parameters of json.dumps (expecially to support custom encoders). Test suite updated to support the update.

@untitaker
Copy link
Contributor

But that would break all existing code that currently uses jsonify!

@anas-aldrees
Copy link

Add it as a new function, mark the old function as depreciated.
On Jul 5, 2013 12:13 AM, "Markus Unterwaditzer" notifications@github.com
wrote:

But that would break all existing code that currently uses jsonify!


Reply to this email directly or view it on GitHubhttps://github.com//pull/790#issuecomment-20493689
.

@devilicecream
Copy link
Author

You're right, sorry!
My original idea was to make a decorator that works as jsonify, but
allowing the behaviour I used in my code... Do you think it could be a good
improvement?

2013/7/4 Markus Unterwaditzer notifications@github.com

But that would break all existing code that currently uses jsonify!


Reply to this email directly or view it on GitHubhttps://github.com//pull/790#issuecomment-20493689
.

@untitaker
Copy link
Contributor

devilicecream, i honestly don't know. I never had the need for custom json encoders. I always convert my data to native types before passing to jsonify, mostly because the explicitness gives me some sense of security. I can see why people would want to use it though.

@untitaker
Copy link
Contributor

Maybe split the current jsonify into one func that takes stdlib-like args, and a second one that wraps the first one?

@devilicecream
Copy link
Author

I like this solution. I'm doing it :) thank u!

2013/7/4 Markus Unterwaditzer notifications@github.com

Maybe split the current jsonify into one func that takes stdlib-like args,
and a second one that wraps the first one?


Reply to this email directly or view it on GitHubhttps://github.com//pull/790#issuecomment-20493973
.

…er for the new implementation. Added test functions for json_encode and json security
@devilicecream
Copy link
Author

Done as a wrapper, but i'm not really sure about this implementation. Maybe it will be better if i made both functions indipendent from the other. Waiting for suggests

@DasIch
Copy link
Contributor

DasIch commented Jul 5, 2013

You can already use a custom encoder by subclassing Flask and overriding the json_encoder class attribute see http://flask.pocoo.org/docs/api/#flask.Flask.json_encoder

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants