Skip to content

JSON number handling breaking change - #26848

Merged
IEvangelist merged 2 commits into
dotnet:mainfrom
gewarren:numberhandling
Nov 8, 2021
Merged

JSON number handling breaking change#26848
IEvangelist merged 2 commits into
dotnet:mainfrom
gewarren:numberhandling

Conversation

@gewarren

@gewarren gewarren commented Nov 6, 2021

Copy link
Copy Markdown
Collaborator

Fixes #26771

Preview

@IEvangelist IEvangelist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I had one nit, otherwise looks good to me, :shipit: when you're ready.

---
# JsonNumberHandlingAttribute on collection properties

A minor breaking change was introduced in .NET 6 with regard to the <xref:System.Text.Json.Serialization.JsonNumberHandlingAttribute> attribute. If you apply the attribute to a property that's a collection of non-number values and attempt to serialize or deserialize the property, an <xref:System.InvalidOperationException> is thrown. The attribute is only valid for properties that are collections of number types, for example:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
A minor breaking change was introduced in .NET 6 with regard to the <xref:System.Text.Json.Serialization.JsonNumberHandlingAttribute> attribute. If you apply the attribute to a property that's a collection of non-number values and attempt to serialize or deserialize the property, an <xref:System.InvalidOperationException> is thrown. The attribute is only valid for properties that are collections of number types, for example:
A breaking change was introduced in .NET 6 with regard to the <xref:System.Text.Json.Serialization.JsonNumberHandlingAttribute> attribute. If you apply the attribute to a property that's a collection of non-number values and attempt to serialize or deserialize the property, an <xref:System.InvalidOperationException> is thrown. The attribute is only valid for properties that are collections of number types, for example:

I'm not sure it's a good idea to classify this as a "minor" breaking change. Any one who had code in place before that used this attribute in this way, would now experience an exception. It's still a breaking change, even though it may not affect as many consumers.

@IEvangelist
IEvangelist merged commit df079a7 into dotnet:main Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Breaking change]: [JsonNumberHandling] on collection of non-number properties

3 participants