The Free Software Media System - Server Backend & API
Use JsonSerializer.SerializeToUtf8Bytes when doing a round trip
Bond_009a9b497720dcb
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.csindex 660ec106bd..c63eb70179 100644--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs@@ -515,7 +515,7 @@ namespace Emby.Server.Implementations.Library}// TODO: @bond Fix- var json = JsonSerializer.Serialize(mediaSource, _jsonOptions);+ var json = JsonSerializer.SerializeToUtf8Bytes(mediaSource, _jsonOptions);_logger.LogInformation("Live stream opened: " + json);var clone = JsonSerializer.Deserialize<MediaSourceInfo>(json, _jsonOptions);diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.csindex 7842be7164..63a3146aa9 100644--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs@@ -2239,7 +2239,7 @@ namespace Emby.Server.Implementations.LiveTvpublic async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true){- info = JsonSerializer.Deserialize<TunerHostInfo>(JsonSerializer.Serialize(info));+ info = JsonSerializer.Deserialize<TunerHostInfo>(JsonSerializer.SerializeToUtf8Bytes(info));var provider = _tunerHosts.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));@@ -2283,7 +2283,7 @@ namespace Emby.Server.Implementations.LiveTv{// Hack to make the object a pure ListingsProviderInfo instead of an AddListingProvider// ServerConfiguration.SaveConfiguration crashes during xml serialization for AddListingProvider- info = JsonSerializer.Deserialize<ListingsProviderInfo>(JsonSerializer.Serialize(info));+ info = JsonSerializer.Deserialize<ListingsProviderInfo>(JsonSerializer.SerializeToUtf8Bytes(info));var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.csindex c3b6af76ea..65fd1654c3 100644--- a/MediaBrowser.Controller/Entities/CollectionFolder.cs+++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs@@ -123,7 +123,7 @@ namespace MediaBrowser.Controller.Entities{LibraryOptions[path] = options;- var clone = JsonSerializer.Deserialize<LibraryOptions>(JsonSerializer.Serialize(options, _jsonOptions), _jsonOptions);+ var clone = JsonSerializer.Deserialize<LibraryOptions>(JsonSerializer.SerializeToUtf8Bytes(options, _jsonOptions), _jsonOptions);foreach (var mediaPath in clone.PathInfos){if (!string.IsNullOrEmpty(mediaPath.Path))