Serialize PosAppCartItem.value as decimal instead of string

This commit is contained in:
nicolas.dorier 2023-07-11 15:49:16 +09:00
parent 1600dd4759
commit b5f0924651
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
2 changed files with 10 additions and 8 deletions

View File

@ -1162,6 +1162,14 @@ namespace BTCPayServer.Tests
}
}.ToString();
Assert.Equal(1.65m, JsonConvert.DeserializeObject<PosAppCartItem>(data).Price);
data = new JObject()
{
["price"] = new JObject()
{
["value"] = "1.6305"
}
}.ToString();
Assert.Equal(1.6305m, JsonConvert.DeserializeObject<PosAppCartItem>(data).Price);
data = new JObject()
{

View File

@ -85,13 +85,7 @@ public class PosAppCartItemPriceJsonConverter : JsonConverter
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
switch (value)
{
case null:
break;
case decimal x:
writer.WriteValue(x.ToString(CultureInfo.InvariantCulture));
break;
}
if (value is decimal x)
writer.WriteValue(x);
}
}