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

ClientResponse.json() should support support object_hook callback #3667

Closed
raees-khan opened this issue Mar 25, 2019 · 2 comments
Closed

ClientResponse.json() should support support object_hook callback #3667

raees-khan opened this issue Mar 25, 2019 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement outdated

Comments

@raees-khan
Copy link

raees-khan commented Mar 25, 2019

Adding support for object_hook callback in json method of ClientResponse object should be considered (i.e. response.json(object_hook=mycallback)).

EDIT:
Basically what I am asking is that the json method should allow us to pass any optional arguments that the JSONDecoder accepts.

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #976 (Fix websocket json support), #1670 (ClientResponse ergonomics), #1185 (Support HPKP), #1760 (support for ujson as json parser), and #17 (oauthlib support).

@aio-libs-bot aio-libs-bot added documentation Improvements or additions to documentation enhancement labels Mar 25, 2019
@asvetlov
Copy link
Member

Please use await response.json(loads=JSONDecoder(object_hook=mycallback).decode)
loads is a callback that accepts a string and returns decoded python object.
Any implementation can be used, e.g. ujson or rapidjson. Not all alternatives have JSONDecoder class which accepts object_hook parameter.

@lock lock bot added the outdated label Apr 17, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation enhancement outdated
Projects
None yet
Development

No branches or pull requests

3 participants