From ef64b11f7ab489fbf0c304cdd14bbd45f9a32c43 Mon Sep 17 00:00:00 2001 From: d11n Date: Wed, 19 Jun 2024 15:31:13 +0200 Subject: [PATCH] TimeSpan JSON Converter: Parse strings (#6012) Something I came across while working in the app: Without this, the [TimeSpan default values of the StoreBlob](https://github.com/btcpayserver/btcpayserver/blob/master/BTCPayServer/Data/StoreBlob.cs#L84) cannot be parsed and don't get applied properly. --- BTCPayServer.Client/JsonConverters/TimeSpanJsonConverter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BTCPayServer.Client/JsonConverters/TimeSpanJsonConverter.cs b/BTCPayServer.Client/JsonConverters/TimeSpanJsonConverter.cs index fb12a1765..e41a809b7 100644 --- a/BTCPayServer.Client/JsonConverters/TimeSpanJsonConverter.cs +++ b/BTCPayServer.Client/JsonConverters/TimeSpanJsonConverter.cs @@ -58,6 +58,8 @@ namespace BTCPayServer.Client.JsonConverters return null; return TimeSpan.Zero; } + if (reader.TokenType == JsonToken.String && TimeSpan.TryParse(reader.Value?.ToString(), out var res)) + return res; if (reader.TokenType != JsonToken.Integer) throw new JsonObjectException("Invalid timespan, expected integer", reader); return ToTimespan((long)reader.Value);