You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JsonSerializer should serialize tuples by default #70352
api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Jsonin-prThere is an active PR which will close this issue when it is mergedwishlistIssue we would like to prioritize, but we can't commit we will get to it yet
@krwq My guess is you are talking about ValueTuples, not Tuples actually.
IMHO it is unfortunate that JSON serializer was released in such shape (i.e. without support for value tuples), but since it is done, changing default behaviour could be risky. I think safe feature we all could agree on, would be to provide default ValueTuple converter.
This at least would allow to easy enabling it.
Reacted by Taco Droogers, Krzysztof Wicher, Vazde and Cole Tobin
Sadly the issue was opened more than 2 years ago and still people are waiting for some meaningful solution. @ericstj@stephentoub Any way to get some help on this?
Reacted by ruslan-yefimov, ltbyun, OpenByte, Matt, Boris Bopp and Cole Tobin
If tuples are not to be supported OOTB, that's fine. But the source generator should not act like it succeeds and write empty objects. After 3.5 years, can we at least get an analyzer warning that tuples won't be serialized without IncludeFields=true?
It might be reasonable to report a warning when serializing a type which has fields but no properties applicable for serialization, and IncludeFields=true is not specified. Tuples seem to fall into that category, and, perhaps if a different default behavior were adopted in the future, it could be opted out of the diagnostic at that time.
api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Jsonin-prThere is an active PR which will close this issue when it is mergedwishlistIssue we would like to prioritize, but we can't commit we will get to it yet
Activity
eiriktsarpalis commentedon Jun 7, 2022
One issue with the current serialization of tuples is that it doesn't handle arities > 7 well:
We might want to consider exposing an opt-in converter that treats tuples as heterogeneous arrays:
And works with large arities as expected:
huoyaoyuan commentedon Jun 7, 2022
Yes, please. Some apis use array to represent tuples, and would contain different types of elements within an array.
macias commentedon Aug 25, 2023
@krwq My guess is you are talking about ValueTuples, not Tuples actually.
IMHO it is unfortunate that JSON serializer was released in such shape (i.e. without support for value tuples), but since it is done, changing default behaviour could be risky. I think safe feature we all could agree on, would be to provide default ValueTuple converter.
This at least would allow to easy enabling it.
chillitom commentedon Jan 17, 2024
Anyone have an implementation of such a
JsonArrayTupleConverter?gregsdennis commentedon Jan 17, 2024
@chillitom ☝️
I've just released Json.More.Net v1.10.0 which includes a
JsonArrayTupleConverter.Should work with any size tuple. Let me know if you have problems.
Sandeep7OnShell commentedon Dec 2, 2024
Sadly the issue was opened more than 2 years ago and still people are waiting for some meaningful solution. @ericstj @stephentoub Any way to get some help on this?
colejohnson66 commentedon Oct 7, 2025
If tuples are not to be supported OOTB, that's fine. But the source generator should not act like it succeeds and write empty objects. After 3.5 years, can we at least get an analyzer warning that tuples won't be serialized without
IncludeFields=true?RikkiGibson commentedon Oct 7, 2025
It might be reasonable to report a warning when serializing a type which has fields but no properties applicable for serialization, and
IncludeFields=trueis not specified. Tuples seem to fall into that category, and, perhaps if a different default behavior were adopted in the future, it could be opted out of the diagnostic at that time.Bump ZiggyCreatures.FusionCache and ZiggyCreatures.FusionCache.Backpl…
Bump ZiggyCreatures.FusionCache and ZiggyCreatures.FusionCache.Serial…
Bump ZiggyCreatures.FusionCache and ZiggyCreatures.FusionCache.Serial…
Bump ZiggyCreatures.FusionCache and ZiggyCreatures.FusionCache.Backpl…