Message328897
When creating a custom class that doesn't inherit from the accepted classes, there is no way to serialize it using json.dumps or json.dump.
I propose that __fromjson__ and __tojson__ that when present will be used by the Python's default encoder. This issue is widely documented on stackoverflow as a deficiency.
You basically have a couple of options to solve this:
1. Implement a custom json.JSONEncoder/json.JSONDecoder
2. Implement a method like to/from json
3. Monkey patch the json library
4. Use a 3rd party library
These are not very good options. If you can serialize an object using pickle, why not have the ability to serialize objects using json?
Thank you |
|
Date |
User |
Action |
Args |
2018-10-30 11:43:02 | andrewchap | set | recipients:
+ andrewchap |
2018-10-30 11:43:02 | andrewchap | set | messageid: <1540899782.53.0.788709270274.issue35111@psf.upfronthosting.co.za> |
2018-10-30 11:43:02 | andrewchap | link | issue35111 messages |
2018-10-30 11:43:02 | andrewchap | create | |
|