mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-24 11:05:08 +01:00
Merge pull request #4715 from crobibero/hdhr-json-bool
Add number to bool json converter
(cherry picked from commit 0aad17554c)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
committed by
Joshua M. Boniface
parent
e8e1bbffd9
commit
2e5333c1d4
23
tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs
Normal file
23
tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Text.Json;
|
||||
using MediaBrowser.Common.Json.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Common.Tests.Json
|
||||
{
|
||||
public static class JsonBoolNumberTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("1", true)]
|
||||
[InlineData("0", false)]
|
||||
[InlineData("2", true)]
|
||||
[InlineData("true", true)]
|
||||
[InlineData("false", false)]
|
||||
public static void Deserialize_Number_Valid_Success(string input, bool? output)
|
||||
{
|
||||
var options = new JsonSerializerOptions();
|
||||
options.Converters.Add(new JsonBoolNumberConverter());
|
||||
var value = JsonSerializer.Deserialize<bool>(input, options);
|
||||
Assert.Equal(value, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user