-
Notifications
You must be signed in to change notification settings - Fork 877
feat: Add System.Text.Json serialization/deserialization supports #10217
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
Conversation
165bb8a
to
cf7bf6c
Compare
46ab297
to
cab3a99
Compare
cab3a99
to
e137e2d
Compare
e137e2d
to
fed5d64
Compare
fed5d64
to
e7c8a77
Compare
e7c8a77
to
750bb7d
Compare
ae390e1
to
850625c
Compare
@filzrev is this PR ready for review and merge? |
Yes. it's ready for review. When this PR is merged and expected and released. Because of following incompatibility exists.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @filzrev . These changes looks good. There are a few conflicts need resolved before I merge.
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
)