aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2020-08-23 16:27:24 +0200
committerGitHub <noreply@github.com>2020-08-23 16:27:24 +0200
commit7ce21d436baa2ffe80e7723f3d0887db7a0eeaf1 (patch)
tree098adec7e4b207bd055fecf417655cb863f09f8f
parentf9bb79285b672e63054b4ab1b49b744606851c34 (diff)
parent340f83c3f5e0f42e7b02be0e4402e2039f8fe734 (diff)
Merge pull request #3961 from crobibero/api-json-null
Ignore null json values
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs3
-rw-r--r--Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs2
-rw-r--r--MediaBrowser.Common/Json/JsonDefaults.cs3
3 files changed, 7 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 5bf740cfc..48e2f5d4a 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -90,6 +90,9 @@ namespace Emby.Server.Implementations.Data
_typeMapper = new TypeMapper();
_jsonOptions = JsonDefaults.GetOptions();
+ // GetItem throws NotSupportedException with this enabled, so hardcode false.
+ _jsonOptions.IgnoreNullValues = false;
+
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
}
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
index 2e2bfea68..1f9fc7078 100644
--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
@@ -168,6 +168,8 @@ namespace Jellyfin.Server.Extensions
// From JsonDefaults
options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;
options.JsonSerializerOptions.WriteIndented = jsonOptions.WriteIndented;
+ options.JsonSerializerOptions.IgnoreNullValues = jsonOptions.IgnoreNullValues;
+
options.JsonSerializerOptions.Converters.Clear();
foreach (var converter in jsonOptions.Converters)
{
diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs
index 0a661934e..891715b3d 100644
--- a/MediaBrowser.Common/Json/JsonDefaults.cs
+++ b/MediaBrowser.Common/Json/JsonDefaults.cs
@@ -24,7 +24,8 @@ namespace MediaBrowser.Common.Json
var options = new JsonSerializerOptions
{
ReadCommentHandling = JsonCommentHandling.Disallow,
- WriteIndented = false
+ WriteIndented = false,
+ IgnoreNullValues = true
};
options.Converters.Add(new JsonGuidConverter());