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.
This commit is contained in:
d11n 2024-06-19 15:31:13 +02:00 committed by nicolas.dorier
parent 9cbea55c2a
commit ef64b11f7a
No known key found for this signature in database
GPG key ID: 6618763EF09186FE

View file

@ -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);