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

Update JsonSerializerOptions.xml #10330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

RickDMyers
Copy link

Refine IncludeFields remarks to highlight that only public fields are serialized and that private fields are not.

Summary

Revised the documentation for JsonSerializerOptions.IncludeFields property clarify that setting the property
to true will only result in 'public' fields being serialized, private fields are not serialized.

Refine IncludeFields remarks to highlight that only public
fields are serialized and that private fields are not.
@RickDMyers RickDMyers requested a review from a team as a code owner August 28, 2024 13:43
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 28, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json

Copy link

Learn Build status updates of commit 238352d:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Text.Json/JsonSerializerOptions.xml ✅Succeeded View

For more details, please refer to the build report.

For any questions, please:

Comment on lines +714 to +715
<remarks>Only includes public fields during serialization and deserialization. Private fields are not included, even if IncludeFields is set to <see langword="true" />.
If you need to include private fields, you would typically use properties with appropriate accessors or consider using attributes like [JsonInclude] on those fields.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<remarks>Only includes public fields during serialization and deserialization. Private fields are not included, even if IncludeFields is set to <see langword="true" />.
If you need to include private fields, you would typically use properties with appropriate accessors or consider using attributes like [JsonInclude] on those fields.
<remarks>This flag only enables serialization for public fields, as is the case for properties.
Private members need to be opted into individually using the <see cref="T:System.Text.Json.Serialization.JsonIncludeAttribute" /> attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Text.Json community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants