No mention of struct serialization?
Type of issue
Missing information
Description
Since struct serialization wasn't always supported, it would be nice to officially state that it now is, e.g. in the Serialization behavior section.
Page URL
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/how-to
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/serialization/system-text-json/how-to.md
Document Version Independent Id
002f9f2a-48d1-0671-a079-b99b9f6bab58
Article author
@gewarren
Metadata
- ID: 588ae32f-3429-143f-824c-5ab2d046d24a
- Service: dotnet-fundamentals
Adding an (tiny) example with a struct could also be worth considering.
@eiriktsarpalis Can you weigh in?
We have a supported collection types article already but not a general "supported types". Perhaps it makes sense to generalize it and include explicit mention of all supported kinds, roughly:
Serializing as JSON objects
The following types serialize as JSON objects unless they implement IEnumerable<T>
- Classes
- Structs
- Interfaces
- Records and struct records
Serializing as JSON arrays
(insert existing content about collection types)
Unupported types
- System.Type and System.Reflection.MemberInfo
ReadOnlySpan<T>,Span<T>and ref structs in general- Delegate types
IntPtrandUIntPtr.