1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Converter fixes

This commit is contained in:
JKorf 2024-02-26 14:28:34 +01:00
parent d18514d73c
commit 0cff678c2d
2 changed files with 7 additions and 5 deletions

View File

@ -26,7 +26,12 @@ namespace CryptoExchange.Net.Converters
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
if (reader.Value == null)
{
if (objectType == typeof(DateTime))
return default(DateTime);
return null;
}
if(reader.TokenType is JsonToken.Integer)
{
@ -56,9 +61,6 @@ namespace CryptoExchange.Net.Converters
else if(reader.TokenType is JsonToken.String)
{
var stringValue = (string)reader.Value;
if (string.IsNullOrWhiteSpace(stringValue))
return null;
if (string.IsNullOrWhiteSpace(stringValue)
|| stringValue == "-1"
|| (double.TryParse(stringValue, out var doubleVal) && doubleVal == 0))

View File

@ -2,7 +2,7 @@
using System;
using System.Globalization;
namespace Kraken.Net.Converters
namespace CryptoExchange.Net.Converters
{
/// <summary>
/// Converter for serializing decimal values as string
@ -14,7 +14,7 @@ namespace Kraken.Net.Converters
/// <inheritdoc />
public override bool CanConvert(Type objectType) => objectType == typeof(decimal) || objectType == typeof(decimal?);
/// <inheritdoc />
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{