Add support for deserializing Char types
authorAndreia Gaita <avidigal@novell.com>
Tue, 27 Jul 2010 19:03:23 +0000 (20:03 +0100)
committerAndreia Gaita <avidigal@novell.com>
Tue, 27 Jul 2010 19:12:02 +0000 (20:12 +0100)
* JsonSerializationReader.cs: Add Char type to the switch. Reads the
  content as a string and validates its length

mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs

index 521c4980549cb958070065a65c3fff0c61bd5267..e0d70bd8051484c7159183a36fbcd36865a8a590 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-27  Andreia Gaita  <avidigal@novell.com>
+
+       * JsonSerializationReader.cs: Add Char type to the switch. Reads the
+         content as a string and validates its length
+
 2010-07-27  Andreia Gaita  <avidigal@novell.com>
 
        * JsonSerializationReader.cs, JsonSerializationWriter.cs:
index c921a49780c5616acd1baec982d80241a2ecfc18..833f223828090ef49ae301eec9f05882b2e3b35a 100644 (file)
@@ -86,6 +86,11 @@ namespace System.Runtime.Serialization.Json
                                }
                                else
                                        return reader.ReadElementContentAsString ();
+                       case TypeCode.Char:
+                               var c = reader.ReadElementContentAsString ();
+                               if (c.Length > 1)
+                                       throw new XmlException ("Invalid JSON char");
+                               return Char.Parse(c);
                        case TypeCode.Single:
                                return reader.ReadElementContentAsFloat ();
                        case TypeCode.Double: