skip to Main Content

How do you properly deserialize a class that has an IReadOnlyCollection<T> using System.Text.Json?

I have the following class: public sealed class SomeClass { [JsonConstructor()] public SomeClass(IEnumerable<string> myItems) { InternalMyItems = new Collection<string>(myItems.ToArray()); MyItems = new ReadOnlyCollection<string>(InternalMyItems); } public IReadOnlyCollection<string> MyItems { get; } private Collection<string> InternalMyItems { get; } } Serialization seems to…

VIEW QUESTION
Back To Top
Search