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

Set json encoder/decoder via config #99

Closed
wants to merge 1 commit into from

Conversation

xuru
Copy link

@xuru xuru commented Dec 30, 2017

Allows for custom serialization/deserialization and defaults to the built json encoder/decoder. This also sets the encoder/decoder for all places json.dump(s) and json.load(s) is used (i.e. gen_unique_id).

This allows you to use a custom encoder/decoder and still use unique=True on tasks.

TODO: add tests, and docs

Better json serialization/deserialization
@thomasst
Copy link
Member

thomasst commented Jan 4, 2018

Thanks! Any downside on doing it the way #92 or #22 do it? Those give additional flexibility since they allow for encoders/decoders other than JSON.

@xuru
Copy link
Author

xuru commented Jan 5, 2018

No downside, but I'm using flask/jinja2 and I just use the same encoder/decoder here.

One thing we could do, is specify the serialization method, and the encoder/decoders that go with it. So, something like:

self.config = {
    'SERIALIZATION_METHOD': 'json',
    'SERIALIZATION_ENCODER': JSONEncoder,
    'SERIALIZATION_DECODER': JSONDecoder,

which would open the door to something like using yaml, or pickle.

I can add this if you like this weekend.

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

Successfully merging this pull request may close these issues.

2 participants