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 GitHub
parent f8f98ab7f0
commit b898fd0ec1

View File

@@ -58,6 +58,8 @@ namespace BTCPayServer.Client.JsonConverters
return null; return null;
return TimeSpan.Zero; return TimeSpan.Zero;
} }
if (reader.TokenType == JsonToken.String && TimeSpan.TryParse(reader.Value?.ToString(), out var res))
return res;
if (reader.TokenType != JsonToken.Integer) if (reader.TokenType != JsonToken.Integer)
throw new JsonObjectException("Invalid timespan, expected integer", reader); throw new JsonObjectException("Invalid timespan, expected integer", reader);
return ToTimespan((long)reader.Value); return ToTimespan((long)reader.Value);