-
Notifications
You must be signed in to change notification settings - Fork 4.9k
JsonSerializerOptions API update and ignore property features #36776
Conversation
src/System.Text.Json/src/System/Text/Json/Serialization/JsonIgnoreAttribute.cs
Show resolved
Hide resolved
|
||
internal abstract object GetValueAsObject(object obj, JsonSerializerOptions options); | ||
bool hasIgnoreAttribute = (GetAttribute<JsonIgnoreAttribute>() != null); |
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.
nit: remove unnecessary brackets.
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.
I have a slight preference and think the brackets make it more obvious that this is a bool... Willing to change it however if I'm the only one :)
src/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfo.cs
Outdated
Show resolved
Hide resolved
src/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfo.cs
Outdated
Show resolved
Hide resolved
options = new JsonSerializerOptions(); | ||
options.WriteIndented = true; | ||
json = JsonSerializer.ToString(obj, options); | ||
Assert.Contains("\r", json); |
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.
I am surprised this is passing on unix.
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.
Yes... I assume the writer is using Environment.NewLine?
21ac47b
to
6a24905
Compare
@@ -162,7 +162,7 @@ public JsonCommentHandling ReadCommentHandling | |||
} | |||
|
|||
/// <summary> | |||
/// Defines whether the <see cref="Utf8JsonWriter"/> should pretty print the JSON which includes: | |||
/// Defines whether JSON should pretty print which includes: |
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.
JSON should be pretty printed
Apply the approved API changes. Includes some new functionality including an [Ignore] that can be applied to properties and ability to ignore just read-only properties on serialization via options.IgnoreReadOnlyProperties.
Fixes https://github.com/dotnet/corefx/issues/34372