mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Don't recreate JsonSerializerOptions every time
This commit is contained in:
parent
ee03b919f9
commit
9f567e6471
@ -9,6 +9,8 @@ namespace MediaBrowser.Common.Json
|
||||
/// </summary>
|
||||
public static class JsonDefaults
|
||||
{
|
||||
private static JsonSerializerOptions _defaultOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default <see cref="JsonSerializerOptions" /> options.
|
||||
/// </summary>
|
||||
@ -20,6 +22,8 @@ namespace MediaBrowser.Common.Json
|
||||
/// </remarks>
|
||||
/// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns>
|
||||
public static JsonSerializerOptions GetOptions()
|
||||
{
|
||||
if (_defaultOptions == null)
|
||||
{
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
@ -34,7 +38,11 @@ namespace MediaBrowser.Common.Json
|
||||
options.Converters.Add(new JsonInt64Converter());
|
||||
options.Converters.Add(new JsonDoubleConverter());
|
||||
|
||||
return options;
|
||||
_defaultOptions = options;
|
||||
return _defaultOptions;
|
||||
}
|
||||
|
||||
return _defaultOptions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user