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

Allow custom json encoder / decoder #714

Closed
samuelcolvin opened this issue Aug 5, 2019 · 7 comments
Closed

Allow custom json encoder / decoder #714

samuelcolvin opened this issue Aug 5, 2019 · 7 comments
Labels
Milestone

Comments

@samuelcolvin
Copy link
Owner

@samuelcolvin samuelcolvin commented Aug 5, 2019

makes more sense, perhaps we could have dump_json and load_json attributes of Config which are then used in parse_json(), json() and schema_json() (and anywhere else we use encode/decode json that I've forgotten about).

Originally posted by @samuelcolvin in #599 (comment)

@samuelcolvin

This comment has been minimized.

Copy link
Owner Author

@samuelcolvin samuelcolvin commented Aug 5, 2019

as discussed in #599 @pablogamboa suggested allowing a custom JSON encoder / decoder library.

This would allow libraries like orjson to be used without making them explicit dependencies of pydantic.

The problem here is going to be how to deal with the default argument with standard lib json and orjson allow, but not ujson.

@samuelcolvin samuelcolvin added this to the Version 1 milestone Aug 5, 2019
@samuelcolvin

This comment has been minimized.

Copy link
Owner Author

@samuelcolvin samuelcolvin commented Aug 5, 2019

If this requires a breaking change it should be done with the bump to version 1.

@MrMrRobat

This comment has been minimized.

Copy link
Contributor

@MrMrRobat MrMrRobat commented Aug 5, 2019

Did you think about implementing something similar to @JrooTJunior done in https://github.com/aiogram/aiogram/blob/dev-2.x/aiogram/utils/json.py?

@samuelcolvin

This comment has been minimized.

Copy link
Owner Author

@samuelcolvin samuelcolvin commented Aug 5, 2019

I would prefer more like the json_serialize argument in aiohttp, so the end user is responsible for implementing a function that correct encodes or decodes JSON.

@JrooTJunior

This comment has been minimized.

Copy link

@JrooTJunior JrooTJunior commented Aug 5, 2019

Yes. json_serialize is more good way.

I want to remove this code from aiogram.

https://github.com/aiogram/aiogram/blob/dev-2.x/aiogram/utils/json.py

@dutradda

This comment has been minimized.

Copy link

@dutradda dutradda commented Aug 22, 2019

@samuelcolvin
is anyone implementing this now?
If not, I want to implement this feature.

@samuelcolvin

This comment has been minimized.

Copy link
Owner Author

@samuelcolvin samuelcolvin commented Aug 24, 2019

No one has started this. PR very welcome.

samuelcolvin added a commit that referenced this issue Sep 20, 2019
@samuelcolvin samuelcolvin mentioned this issue Sep 20, 2019
3 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.