mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 06:23:03 +03:00
Fix Json Enum conversion, map all JsonDefaults properties to API
This commit is contained in:
@@ -12,10 +12,16 @@ namespace MediaBrowser.Common.Json
|
||||
/// <summary>
|
||||
/// Gets the default <see cref="JsonSerializerOptions" /> options.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When changing these options, update
|
||||
/// Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
|
||||
/// -> AddJellyfinApi
|
||||
/// -> AddJsonOptions
|
||||
/// </remarks>
|
||||
/// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns>
|
||||
public static JsonSerializerOptions GetOptions()
|
||||
{
|
||||
var options = new JsonSerializerOptions()
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
ReadCommentHandling = JsonCommentHandling.Disallow,
|
||||
WriteIndented = false
|
||||
@@ -26,5 +32,31 @@ namespace MediaBrowser.Common.Json
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets CamelCase json options.
|
||||
/// </summary>
|
||||
public static JsonSerializerOptions CamelCase
|
||||
{
|
||||
get
|
||||
{
|
||||
var options = GetOptions();
|
||||
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets PascalCase json options.
|
||||
/// </summary>
|
||||
public static JsonSerializerOptions PascalCase
|
||||
{
|
||||
get
|
||||
{
|
||||
var options = GetOptions();
|
||||
options.PropertyNamingPolicy = null;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user