docs icon indicating copy to clipboard operation
docs copied to clipboard

No mention of struct serialization?

Open fterrani opened this issue 1 year ago • 1 comments

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

Related Issues

fterrani avatar Oct 08 '24 16:10 fterrani

Adding an (tiny) example with a struct could also be worth considering.

fterrani avatar Oct 08 '24 16:10 fterrani

@eiriktsarpalis Can you weigh in?

gewarren avatar Oct 23 '24 19:10 gewarren

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
  • IntPtr and UIntPtr.

eiriktsarpalis avatar Oct 23 '24 19:10 eiriktsarpalis