1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

Fix failing tests (#2095)

This commit is contained in:
Oscar Hinton
2022-07-05 18:39:43 +02:00
committed by GitHub
parent 113627dcd5
commit 45a005d652
3 changed files with 21 additions and 10 deletions

View File

@ -1,4 +1,5 @@
using System.Text.Json;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
using NS = Newtonsoft.Json;
@ -140,14 +141,15 @@ namespace Bit.Core.Utilities
/// </summary>
public class PermissiveStringConverter : JsonConverter<string>
{
internal static PermissiveStringConverter Instance = new();
internal static readonly PermissiveStringConverter Instance = new();
private static readonly CultureInfo _cultureInfo = new("en-US");
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.TokenType switch
{
JsonTokenType.String => reader.GetString(),
JsonTokenType.Number => reader.GetDecimal().ToString(),
JsonTokenType.Number => reader.GetDecimal().ToString(_cultureInfo),
JsonTokenType.True => bool.TrueString,
JsonTokenType.False => bool.FalseString,
_ => throw new JsonException($"Unsupported TokenType: {reader.TokenType}"),