Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties of custom collections are not serialized with JSON serialization #22402

Closed
3 tasks
christiannagel opened this issue Jan 18, 2021 · 2 comments
Closed
3 tasks
Assignees
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-fundamentals/svc needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] Pri2

Comments

@christiannagel
Copy link

christiannagel commented Jan 18, 2021

Using JSON serialization (System.Text.Json) of custom collections, it would help adding documentation that the state of collections in addition to the collection is not serialized (e.g. properties of the custom collection).

The documentation at https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-supported-collection-types?pivots=dotnet-5-0 has this information:

System.Text.Json.JsonSerializer supports a collection type for serialization if it:

  • Derives from IEnumerable.
  • Contains elements that are serializable.

The serializer calls the GetEnumerator() method, and writes the elements.

Here, it would be helpful adding this information:

Properties or fields of custom collections are not serialized.

Maybe this information should be added here as well (or only here):

https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-supported-collection-types?pivots=dotnet-5-0#custom-collections

This behavior is described here (along with a project showing this): dotnet/runtime#46920

Target framework

  • [5.0] .NET
  • .NET Core
  • .NET Framework
  • .NET Standard

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@tdykstra
Copy link
Contributor

There's a request for more info in the runtime repo issue: dotnet/runtime#46920 (comment)

@tdykstra tdykstra added the needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] label Mar 30, 2021
@no-response
Copy link

no-response bot commented Apr 13, 2021

This issue has been automatically closed due to no response from the original author. Please feel free to reopen it if you have more information that can help us investigate the issue further.

@no-response no-response bot closed this as completed Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-fundamentals/svc needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] Pri2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants