mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
Fix for handling Nullable types in JSON deserialization
re #328836 svn path=/trunk/mcs/; revision=87847
This commit is contained in:
1 parent
b3408d14bd
commit
407dc6bc3f
1 file changed
+12
+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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user