Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add support for deserializing Char types

* JsonSerializationReader.cs: Add Char type to the switch. Reads the
  content as a string and validates its length
  • Loading branch information...
commit 778694e1b85416a3abfdac4952dd85c8384e1cf8 1 parent 4a6ea9c
Andreia Gaita authored July 27, 2010
5  mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog
... ...
@@ -1,5 +1,10 @@
1 1
 2010-07-27  Andreia Gaita  <avidigal@novell.com>
2 2
 
  3
+	* JsonSerializationReader.cs: Add Char type to the switch. Reads the
  4
+	  content as a string and validates its length
  5
+
  6
+2010-07-27  Andreia Gaita  <avidigal@novell.com>
  7
+
3 8
 	* JsonSerializationReader.cs, JsonSerializationWriter.cs:
4 9
 	  Add a special case for IDictionary, since KeyValuePair objects
5 10
 	  have private setters and can't be processed via the normal
5  mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs
@@ -86,6 +86,11 @@ public object ReadObject (Type type)
86 86
 				}
87 87
 				else
88 88
 					return reader.ReadElementContentAsString ();
  89
+			case TypeCode.Char:
  90
+				var c = reader.ReadElementContentAsString ();
  91
+				if (c.Length > 1)
  92
+					throw new XmlException ("Invalid JSON char");
  93
+				return Char.Parse(c);
89 94
 			case TypeCode.Single:
90 95
 				return reader.ReadElementContentAsFloat ();
91 96
 			case TypeCode.Double:

0 notes on commit 778694e

Please sign in to comment.
Something went wrong with that request. Please try again.