Skip to content
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

JSON Opt-in serialization guidelines or recommendation #38687

Open
zijianhuang opened this issue Dec 9, 2023 · 0 comments
Open

JSON Opt-in serialization guidelines or recommendation #38687

zijianhuang opened this issue Dec 9, 2023 · 0 comments
Labels
doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri3 ⌚ Not Triaged Not triaged

Comments

@zijianhuang
Copy link

Help us make content visible

During .NET Framework era, MSDN provides documents about XML serializations, opt-in or opt-out. Typically, for opt-in, the orthodox way is to use DataContractAttribute and DataMemberAttribute.

And for JSON serializations, the orthodox way is to use NewtonSoft.Json.

However, .NET (Core) had built-in JSON serialization through System.Text.Json and System.Text.Json.Serialization which can mostly replace NewtonSoft.Json.

I have googled "c# serialization text json opt in", and have not found Microsoft recommended way of opt-in serialization of JSON.

The closest one is dotnet/runtime#30180, suggested by layomia :
"This can be achieved using DataContractAttribute and DataMemberAttribute, if we provide support for them: https://github.com/dotnet/corefx/issues/38758. We should be careful not to provide too many ways to do the same thing."

And dotnet/runtime#29975 is probably relevant.

Describe the new article

- Explain why this article is needed.

During .NET Framework era, MSDN provides documents about XML serializations, opt-in and opt-out. Having similar articles for JSON serialization could be balancing. DataContractAttribute is fine, but we need Microsoft's official position about it for preserving our investments on application coding.

Opt-in is more important for generating client API codes from service codes, since a client code generator generally just extract a portion of POCO classes on the service side, and a portion of a POCO class.

@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Dec 9, 2023
@gewarren gewarren added the doc-idea Indicates issues that are suggestions for new topics [org][type][category] label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri3 ⌚ Not Triaged Not triaged
Projects
None yet
Development

No branches or pull requests

3 participants