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

embed JSON within JSON without load/dump steps #125

Closed
wardi opened this issue Oct 13, 2015 · 2 comments
Closed

embed JSON within JSON without load/dump steps #125

wardi opened this issue Oct 13, 2015 · 2 comments

Comments

@wardi
Copy link

wardi commented Oct 13, 2015

I have a JSON-based API that is often returning cached blocks of JSON as part of its responses. The majority of the the time generating responses for users was spent dumping large blocks of JSON into Python dicts, lists etc. only to immediately load them as part of a JSON response. To improve its performance I've written a terrible hack. Since #118 was fixed my terrible hack no longer works.

Instead of making my hack even worse, I would like to submit a change to simplejson that would let me hook the _iterencode step to produce my own raw JSON as part of the encoded result. Would you accept such a change, and how would you like to see it done?

@wardi
Copy link
Author

wardi commented Oct 13, 2015

simplejson supports a for_json method on objects when for_json=True. How about I add a for_raw_json option that behaves the same way, but returns a unicode string containing already-encoded JSON?

@etrepum
Copy link
Member

etrepum commented Oct 13, 2015

I think that there are already too many options, maybe the right thing to do here is to provide a specific class that can be used for this purpose. It can be a bit more backwards compatible given a for_json that returns the parsed contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants