-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed as not planned
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.Json
Milestone
Description
New API:
public static class JsonSerializerOptions
{
// Can only be set until the first (de)serialization occurs (like other properties here)
public static Func<JsonSerializerOptions> Default { get; set; }
}Newtonsoft \ JSON.NET does it this way:
public static class JsonConvert
{
public static Func<JsonSerializerSettings> DefaultSettings { get; set;}
}The upside is that you can have different settings for different situations, including different options per assembly, even though that would require the developer be aware of the potential pitfalls of that. The fact that it has also worked for many years in JSON.NET I think is a plus as well.
Performance could suffer a little bit, would have to test. Either way, one could always get over that by explicitly passing their options.
Original text:
Provide a way to change the default settings for the static JsonSerializer class. In Json.NET, you could do:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings();Currently you have to keep passing the options around and remembering to pass it to each call to [De]Serialize
btecu, tdreid, ashrafsabrym, RasmusWesterlundh, artemutin and 100 more0xced and XyncgasSidShetye, fleed, TanvirArjel, Unknown6656 and Thomas-X
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.Json