Fix deserializing empty string to empty byte array (#1787)

This commit is contained in:
James Newton-King
2018-08-06 15:43:22 +12:00
committed by GitHub
parent 092098933e
commit ad246c775a
2 changed files with 90 additions and 6 deletions
@@ -303,18 +303,18 @@ namespace Newtonsoft.Json.Serialization
case JsonToken.String:
string s = (string)reader.Value;
// convert empty string to null automatically for nullable types
if (CoerceEmptyStringToNull(objectType, contract, s))
{
return null;
}
// string that needs to be returned as a byte array should be base 64 decoded
if (objectType == typeof(byte[]))
{
return Convert.FromBase64String(s);
}
// convert empty string to null automatically for nullable types
if (CoerceEmptyStringToNull(objectType, contract, s))
{
return null;
}
return EnsureType(reader, s, CultureInfo.InvariantCulture, contract, objectType);
case JsonToken.StartConstructor:
string constructorName = reader.Value.ToString();