1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-06 23:46:12 +00:00

Fixed issue with serialization of nullable types in System.Text.Json ArrayConverter

This commit is contained in:
Jkorf 2025-02-05 09:12:12 +01:00
parent 0262f04913
commit 1bbbec7f2b

View File

@ -87,11 +87,11 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
if (prop.JsonConverterType == null && IsSimple(prop.PropertyInfo.PropertyType))
{
if (prop.PropertyInfo.PropertyType == typeof(string))
if (prop.TargetType == typeof(string))
writer.WriteStringValue(Convert.ToString(objValue, CultureInfo.InvariantCulture));
else if(prop.PropertyInfo.PropertyType.IsEnum)
else if(prop.TargetType.IsEnum)
writer.WriteStringValue(EnumConverter.GetString(objValue));
else if (prop.PropertyInfo.PropertyType == typeof(bool))
else if (prop.TargetType == typeof(bool))
writer.WriteBooleanValue((bool)objValue);
else
writer.WriteRawValue(Convert.ToString(objValue, CultureInfo.InvariantCulture)!);