mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Serialize PosAppCartItem.value as decimal instead of string
This commit is contained in:
parent
1600dd4759
commit
b5f0924651
@ -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()
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user