fix: Fixing JSON converter error when handling default existing value with struct types

This commit is contained in:
Chris Cameron
2019-05-10 16:04:11 -04:00
parent cbf7a3d79c
commit 9ad49540d2

View File

@@ -103,7 +103,10 @@ namespace ICD.Common.Utils.Json
if (serializer == null)
throw new ArgumentNullException("serializer");
return ReadJson(reader, (T)existingValue, serializer);
// Casting null blows up struct casts
T cast = (T)(existingValue ?? default(T));
return ReadJson(reader, cast, serializer);
}
/// <summary>