Fix for handling Nullable types in JSON deserialization

re #328836

svn path=/trunk/mcs/; revision=87847
This commit is contained in:
R. Tyler Ballance committed 2007-10-20 11:30:19 +00:00
1 parent b3408d14bd
commit 407dc6bc3f
1 file changed
+12
@@ -206,6 +206,18 @@ namespace System.Web.Script.Serialization
if (obj is IEnumerable<object>)
return ConvertToList ((IEnumerable<object>) obj, type);
/*
* Take care of the special case whereas in JSON an empty string ("") really means
* an empty value
* (see: https://bugzilla.novell.com/show_bug.cgi?id=328836)
*/
if ( (type.IsGenericType) && (type.GetGenericTypeDefinition() == typeof(Nullable<>)) )
{
string s = obj as String;
if (String.IsNullOrEmpty(s))
return null;
}
if (type == null)
return obj;