-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
Team:LibrariesUser StoryA single user-facing feature. Can be grouped under an epic.A single user-facing feature. Can be grouped under an epic.api-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementationarea-System.Text.Jsonpartner-impactThis issue impacts a partner who needs to be kept updatedThis issue impacts a partner who needs to be kept updated
Milestone
Description
JsonConverter allows specifying the conveter to be used for a specific property, however if a collection is in use and you want to use the converter to serialize a items in collection it doesn't work.
Example
public enum Day
{
Sunday,
Monday,
}
public class Model
{
[JsonConverter(typeof(JsonStringEnumConverter))]
public IEnumerable<Day> Days { get; set; }
}The above code will throw. The only way to work around is to write a custom converter which understands collections and uses a different converter for each item in collection.
I propose a new attribute which allows the caller to specify converter to use for items in collection should be added. Something like
[JsonCollectionItemConverter(typeof(JsonStringEnumConverter))]
Newtonsoft.Json allows this by allowing specifying the type in JsonProperty attribute. That option has it's own shortcomings as well. I believe the above option will solve that too.
Akarinnnnn, HeroMaxPower, N0D4N, anreton, virzak and 18 more
Metadata
Metadata
Assignees
Labels
Team:LibrariesUser StoryA single user-facing feature. Can be grouped under an epic.A single user-facing feature. Can be grouped under an epic.api-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementationarea-System.Text.Jsonpartner-impactThis issue impacts a partner who needs to be kept updatedThis issue impacts a partner who needs to be kept updated