lidatong / dataclasses-json

Easily serialize Data Classes to and from JSON
MIT License
1.34k stars 150 forks source link

[BUG] new key "dataclass_json_config": null #506

Open navimac opened 5 months ago

navimac commented 5 months ago

Description

when serializing object with dataclasses-json==0.6.2 I get new key "dataclass_json_config": null, which ruins my serialization and was not present in version 0.6.1 I reverted the change dataclass_json_config: Optional[dict] = None to dataclass_json_config = None and now I don't get this extra key.

Code snippet that reproduces the issue

code is under NDA but basically we use asdict method and then we pass this to a json.dumps method. We also allow that keys can be null

Describe the results you expected

Json file without "dataclass_json_config": null key, value pair

Python version you are using

Python 3.9.16.1

Environment description

alabaster==0.7.13
argparse-addons==0.12.0
attrs==23.1.0 Babel==2.14.0 bitstruct==8.19.0
black==23.9.1 cantools==39.4.0 certifi==2023.11.17
charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 CppHeaderParser==2.7.4 crccheck==1.3.0 dataclasses-json==0.6.2 dataclasses-jsonschema==2.16.0 diskcache==5.6.3 docutils==0.19 idna==3.6 imagesize==1.4.1 importlib-metadata==7.0.0 Jinja2==3.1.2 jsonschema==4.20.0 jsonschema-specifications==2023.11.2 markdown-it-py==3.0.0 MarkupSafe==2.1.3 marshmallow==3.20.1 marshmallow-enum==1.5.1 mdit-py-plugins==0.4.0 mdurl==0.1.2 mypy==1.7.1 mypy-extensions==1.0.0 myst-parser==2.0.0 numpy==1.26.2 packaging==23.2 pathspec==0.12.1 platformdirs==4.1.0 ply==3.11 psutil==5.9.3 Pygments==2.17.2 python-can==4.3.1 python-dateutil==2.8.2 pywin32==306 PyYAML==6.0.1 referencing==0.32.0 requests==2.31.0 rpds-py==0.15.2 six==1.16.0 snowballstemmer==2.2.0 Sphinx==6.2.1 sphinx-argparse==0.4.0 sphinx-rtd-theme==2.0.0 sphinxcontrib-applehelp==1.0.7 sphinxcontrib-devhelp==1.0.5 sphinxcontrib-htmlhelp==2.0.4 sphinxcontrib-images==0.9.4 sphinxcontrib-jquery==4.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-programoutput==0.17 sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 stringcase==1.2.0 textparser==0.24.0 tomli==2.0.1 typeguard==2.13.3 types-psutil==5.9.5.17 types-pywin32==306.0.0.8 types-PyYAML==6.0.12.12 types-requests==2.31.0.10 typing-inspect==0.9.0 typing_extensions==4.9.0 urllib3==2.1.0 wrapt==1.16.0 zipp==3.17.0

navimac commented 5 months ago

@george-zubrienko I created the issue. I can't post part of the code directly but I have described the basic usage. I hope this is ok