allow custom JSONEncoder for the request's json param
See original GitHub issueUsing the json param when making a request is awesome:
payload = {'blip': 'blaz'}
r = requests.get('http://foo.bar', json=payload)
Using the response property is great as well, especially since you can use a custom json decoder:
r.json(cls=MyCustomDecoder)
It would be nice to allow a param to be passed that could be applied to the dumps
of the json value.
payload = {'blip': Decimal(69)}
json_params = {'cls': MyCustomEncoder}
r = requests.get('http://foo.bar', json=payload, json_params=json_params)
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Custom JSONEncoder for requests.post - Stack Overflow
Is there any way to use custom JSON encoder with Request object? Seems I can only use parameter json, but can't find how...
Read more >json — JSON encoder and decoder — Python 3.11.1 ...
To use a custom JSONEncoder subclass (e.g. one that overrides the default() method to serialize additional types), specify it with the cls kwarg;...
Read more >Custom JSON Encoder in Python - PythonForBeginners.com
Create Custom JSON Encoder Using the “cls” Parameter For converting a custom object to JSON, we need to define a custom JSONEncoder subclass ......
Read more >Custom JSON encoder and decoder - Mathspp
This article explains how to extend the JSON format by using a custom encoder and a custom decoder to turn arbitrary Python objects...
Read more >Encoding Custom Types to JSON - Real Python
In this video, you'll learn how to encode non-serializable types into JSON. The dump() and dumps() methods allow us to include an optional...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think the better way is to manually use it yourself:
@drmaples then make a function that handles that “globally” for yourself. We won’t be introducing this.