1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-08 00:16:27 +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) public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{ {
if (reader.Value == null) if (reader.Value == null)
{
if (objectType == typeof(DateTime))
return default(DateTime);
return null; return null;
}
if(reader.TokenType is JsonToken.Integer) if(reader.TokenType is JsonToken.Integer)
{ {
@ -56,9 +61,6 @@ namespace CryptoExchange.Net.Converters
else if(reader.TokenType is JsonToken.String) else if(reader.TokenType is JsonToken.String)
{ {
var stringValue = (string)reader.Value; var stringValue = (string)reader.Value;
if (string.IsNullOrWhiteSpace(stringValue))
return null;
if (string.IsNullOrWhiteSpace(stringValue) if (string.IsNullOrWhiteSpace(stringValue)
|| stringValue == "-1" || stringValue == "-1"
|| (double.TryParse(stringValue, out var doubleVal) && doubleVal == 0)) || (double.TryParse(stringValue, out var doubleVal) && doubleVal == 0))

View File

@ -2,7 +2,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
namespace Kraken.Net.Converters namespace CryptoExchange.Net.Converters
{ {
/// <summary> /// <summary>
/// Converter for serializing decimal values as string /// Converter for serializing decimal values as string