-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Custom JSON encoders and decoders #131
Conversation
Codecov Report
@@ Coverage Diff @@
## master #131 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 19 19
Lines 736 743 +7
Branches 70 71 +1
=====================================
+ Hits 736 743 +7
Continue to review full report at Codecov.
|
I was wondering, would it be better to store the functions in the Taking your example, for the user point of view, you would only need to change the last line to app = App(job_store=PostgresJobStore(dumps=dumps, loads=loads)) |
Great suggestion! I'll look into it… |
9660bc9
to
edf18f2
Compare
2ae6b4a
to
0e24f8e
Compare
Cf. #99 (and #108 for the preliminary work on this).
This PR makes it possible for the user to provide custom JSON encoders and decoders.
The custom encoder and decoder are provided as JSON
dumps
andloads
functions on theApp
object.Here's an example dealing with
datetime
objects:I think the approach provides a maximum of flexibility to the users. They can use the
json
module the way they want. They can even use a different JSON implementation thanjson
, such as UltraJSON, if they want to.I am creating this PR for discussion. The code in my branch (attached to this PR) basically works and is tested, although there's still work to do (typing, documentation, more tests maybe, etc.).
Any feedback?
Successful PR Checklist: