-
Notifications
You must be signed in to change notification settings - Fork 860
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
feat: Add System.Text.Json serialization/deserialization supports #10217
Open
filzrev
wants to merge
23
commits into
dotnet:main
Choose a base branch
from
filzrev:feature/add-system-text-json-supports
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Add System.Text.Json serialization/deserialization supports #10217
filzrev
wants to merge
23
commits into
dotnet:main
from
filzrev:feature/add-system-text-json-supports
Conversation
This file contains 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
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
September 20, 2024 08:22
165bb8a
to
cf7bf6c
Compare
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
September 26, 2024 22:45
46ab297
to
cab3a99
Compare
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
September 26, 2024 22:48
cab3a99
to
e137e2d
Compare
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
September 26, 2024 22:48
e137e2d
to
fed5d64
Compare
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
September 27, 2024 12:29
fed5d64
to
e7c8a77
Compare
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
September 27, 2024 12:48
e7c8a77
to
750bb7d
Compare
filzrev
force-pushed
the
feature/add-system-text-json-supports
branch
from
October 12, 2024 10:36
ae390e1
to
850625c
Compare
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.
This draft PR intended to add functionality for gradual migration from
Newtonsoft.Json
toSystem.Text.Json
. (Related issue #9727)1. chore: refactoring JsonUtility code to support newtonsoftjson/systemtxtjson switching based on type (fda9353)
JsonUtility
related code to support switching NewtonsoftJson/SystemTextJson by type.2. chore: add json/yaml serialization test infrastructure (92a47a6)
Object->YAML->Object
andObject->JSON->Object
)3. chore: switch XRefMap serialization logics to use System.Text.Json (643c89b)
XRefMap
serialization/deserialization to use JsonUtility andSystem.Text.Json
.XRefMap
serialization/deserialization tests.4. chore: add json roundtrip test with JsonUtility (2fa823a)
5. chore: Add MarkdigExtensionSetting json roundtrip tests (7b3dd78)
MarkdigExtensionSetting
.6. chore: add ManagedReference YAML roundtrip tests (9492ef8)
ManagedReference.PageViewModel
private init
andJsonInclude
attribute(It's required because
System.Text.Json
can't deserialize getter-only property)7. chore: add UniversalReference YAML roundtrip tests (12c7394)
UniversalReference.PageViewModel
8. chore: add ApiPage YAML roundtrip tests (448c933)
ApiPage
9. chore: add FilterConfig YAML roundtrip tests (a9fde45)
FilterConfig
Rule
getter-only property.10. chore: Add Manifest model json roundtrip tests (9c13117)
Manifest
init
properties to support System.Text.Json deserialization.11. chore: change JavascriptEncoder settings and add related tests (9466b91)
UnsafeRelaxedJsonEscaping
JSON Serialization Encoder. (By default. all non-ACSII chars are escaped)12. chore: add TOC model YAML roundtrip tests (da94915)
TOC
CustomEqualityEquivalencyStep
that is used byBeEquivalent
comparison that comparing between deserialized models(Newtonsoft/SysteTextJson/YamlDotNet)CustomEqualityEquivalencyStep
behaviors13. chore: add dummy property name for deserialize metadata key data (d101fdc)
__metadata__
) toMetadata
property that usingJsonIgnore
attribute.Without this setting, SystemTextJson skip deserialization of items that have
metadata
key.(See:
https://github.com/dotnet/runtime/issues/68895
)14. chore: add FileMapping/FileItems converters and JSON roundtrip tests (7b06344)
FileMapping/FileItems
15. chore: disable MarkdigExtensionSettingConverter JSON formatting (8eaed9f)
MarkdigExtensionSettingConverter
serialization16. chore: add ListWithStringFallback converters and JSON roundtrip test (948052a)
ListWithStringFallback
17. chore: add FileMetadataPairs converters and JSON roundtrip test (6eb819c)
FileMetadataPairs
EquivalentTo
(NewtonsoftJson deserialize integer to
long
. but SystemTextJson implementation try to deserialize asint
)18. chore: add MergeJsonConfig converters and JSON roundtrip test (b8e4d85)
19. chore: add BuildJsonConfig JSON roundtrip test (80d10a7)
20. chore: add MetadataJsonConfig JSON roundtrip test (c62a025)
21. chore: add DocfxConfig JSON roundtrip test(28c55aa)
22. chore: Switch to use SystemTextJson by default and fix related tests (850625c)
23. chore: modify converter to throw JsonException if unexpected token found (f89752a)
JsonException
.Future tasks (that is not handled in this PR)
RestApiRootItemViewModel
serialization/deserialization to useSystem.Text.Json
JToken
/JObject
Known compatibility issues
string
tobool
/numeric
conversion is not supported by default (e.g. "prop": "true")2.1. numeric value is deserialized as appropriate types (byte/short/long/ulong/float/double)
(NewtonsoftJson deserialize numeric value to fixed type (
long
ordouble
) )2.2.
Dictionary<string, object>
data is deserialized to object dictionary. And child array element is deserialized to List.(
NewtonsoftJson
deserialize these data toJToken
)