-
Notifications
You must be signed in to change notification settings - Fork 155
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
Change case (de)serialization when using DataClassJsonMixin ? #272
Comments
Hi @eLvErDe , can you try this: dataclass_json_config = dataclasses_json.cfg.config(letter_case=dataclasses_json.LetterCase.CAMEL)['dataclasses_json'] I'm not sure if it'll work, but I stole it from here: |
@AbdulRahmanAlHamali thank you for the hint. I put it into a new class for easier reuse: from dataclasses_json import DataClassJsonMixin
import dataclasses_json
class DataClassJsonCamelMixIn(DataClassJsonMixin):
dataclass_json_config = dataclasses_json.config( # type: ignore
letter_case=dataclasses_json.LetterCase.CAMEL, # type: ignore
undefined=dataclasses_json.Undefined.EXCLUDE
)['dataclasses_json'] |
Would love to hear of an API for this! We're using the mixin for the type checking (which is great!) and this particular construction feels a lil funny to add. |
#442 v1 API should make things easier here |
Hello,
I tried to switch from decorator to mixin because Mypy struggles to understand what methods are available but I cannot figure out how to set case handling.
I tried the following:
I also tried to overwrite dataclasses_json.config from file scope with no luck.
How can I do that ?
Thanks.
The text was updated successfully, but these errors were encountered: