-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.JsonuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
Background and Motivation
JsonConverter attribute allows customizing the json serialization and deserialization process. However, today there is no way to specify constructor arguments that the converter themselves take.
Best example of this is JsonStringEnumConverter which has following constructor
public JsonStringEnumConverter(JsonNamingPolicy? namingPolicy = null, bool allowIntegerValues = true)It is pretty common to specify that you want enum members to be camel cased. However, using JsonConveter attribute it is not possible to do this, unless you create another converter which sets that by default.
Newtonsoft.Json supports the following attribute constructor allowing parameters to be specified.
public JsonConverterAttribute(Type converterType, params object[] converterParameters)Proposed API
public JsonConverterAttribute(Type converterType, params object[] converterParameters)Usage Examples
[JsonConverter(typeof(JsonStringEnumConverter), JsonNamingPolicy.CamelCase, true)]Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.JsonuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner