From 238352d79e2ee80dcd49740edea21a48414c1a44 Mon Sep 17 00:00:00 2001 From: Rick Myers Date: Wed, 28 Aug 2024 09:39:30 -0400 Subject: [PATCH 1/2] Update JsonSerializerOptions.xml Refine IncludeFields remarks to highlight that only public fields are serialized and that private fields are not. --- xml/System.Text.Json/JsonSerializerOptions.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xml/System.Text.Json/JsonSerializerOptions.xml b/xml/System.Text.Json/JsonSerializerOptions.xml index e6be2736252..f28f9e8402e 100644 --- a/xml/System.Text.Json/JsonSerializerOptions.xml +++ b/xml/System.Text.Json/JsonSerializerOptions.xml @@ -710,8 +710,10 @@ For more information, see [How to ignore properties with System.Text.Json](/dotn Gets or sets a value that indicates whether fields are handled during serialization and deserialization. The default value is . - if fields are included during serialization; otherwise, . - To be added. + if public fields are included during serialization; otherwise, . + Only includes public fields during serialization and deserialization. Private fields are not included, even if IncludeFields is set to . + If you need to include private fields, you would typically use properties with appropriate accessors or consider using attributes like [JsonInclude] on those fields. + This property is set after serialization or deserialization has occurred. From 4a5ec8d131335ac184e0554294a2478bfd9d4edd Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 30 Oct 2024 08:11:10 -0700 Subject: [PATCH 2/2] Update xml/System.Text.Json/JsonSerializerOptions.xml Co-authored-by: Eirik Tsarpalis --- xml/System.Text.Json/JsonSerializerOptions.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xml/System.Text.Json/JsonSerializerOptions.xml b/xml/System.Text.Json/JsonSerializerOptions.xml index f28f9e8402e..20fb26fdb98 100644 --- a/xml/System.Text.Json/JsonSerializerOptions.xml +++ b/xml/System.Text.Json/JsonSerializerOptions.xml @@ -711,8 +711,8 @@ For more information, see [How to ignore properties with System.Text.Json](/dotn The default value is . if public fields are included during serialization; otherwise, . - Only includes public fields during serialization and deserialization. Private fields are not included, even if IncludeFields is set to . - If you need to include private fields, you would typically use properties with appropriate accessors or consider using attributes like [JsonInclude] on those fields. + This flag only enables serialization for public fields, as is the case for properties. + Private members need to be opted into individually using the attribute. This property is set after serialization or deserialization has occurred.