Improve json API compatibility and preserve core type fidelity#97
Open
danielendler wants to merge 4 commits intomainfrom
Open
Improve json API compatibility and preserve core type fidelity#97danielendler wants to merge 4 commits intomainfrom
danielendler wants to merge 4 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
json.dumps/json.loadsby accepting common stdlib arguments and validating unknown kwargs.tuple,set,frozenset) when type hints are enabled so round-trips do not lose identity.Description
dumps/dumpkwargs into Datason config overrides and allowedjson.dumpskwargs, passing through accepted JSON options likeindent,ensure_ascii,skipkeys,separators, anddefault, while applying config defaults when not provided (datason/_core.py).tuple,set, andfrozensetwheninclude_type_hints=Trueand restore those types onloads, while preserving legacy list output when hints are disabled (datason/_core.py,datason/_deserialize.py).NanHandling.STRINGoutputs to"NaN","Infinity", and"-Infinity"instead of lowercased strings (datason/_core.py).DateFormat.UNIX/UNIX_MSby emitting a small dict containing atimestampandnaivemarker and restoring a naivedatetimewhen appropriate (datason/plugins/datetime.py).json.loads/json.loadparsing kwargs (parse_float,parse_int,object_hook, etc.) and validate unknown kwargs with clearTypeErrormessages (datason/_deserialize.py).tests/unit/test_core.py,tests/unit/test_plugin_datetime.py).Testing
uv run pytest -q, resulting in272 passed, 15 skippedand no failures.uv run pytest tests/unit/test_core.py tests/unit/test_plugin_datetime.py tests/unit/test_deserialize.py -qwhich passed successfully.uv run ruff check datason testswhich produced no issues.dumps/dumpJSON kwargs handling,loadskwargs, collection type fidelity, NaN string normalization, and naive datetime UNIX/UNIX_MS round-trips and passed in CI-local runs.Codex Task