2010-02-24 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 24 Feb 2010 09:46:11 +0000 (09:46 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 24 Feb 2010 09:46:11 +0000 (09:46 -0000)
* JsonWriter.cs : write NaN, INF, -INF as JSON string, not JSON number.
  Fixed bug #573691.

svn path=/trunk/mcs/; revision=152342

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

index a3f7b28e0a998780d06de1e19ce455db73a1ad2f..8a918994b3e080156dd12448de1f47051a4097f2 100644 (file)
@@ -1,3 +1,8 @@
+2010-02-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * JsonWriter.cs : write NaN, INF, -INF as JSON string, not JSON number.
+         Fixed bug #573691.
+
 2010-01-27  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataContractJsonSerializer.cs : KnownTypes does not include root
index 64c85121f7e4967dd723c72e693d87848f0536f6..31ceaa27ce46ba8e933e63192b75d7918581c358 100644 (file)
@@ -364,6 +364,21 @@ namespace System.Runtime.Serialization.Json
                                        }
                                        break;
                                case ElementType.Number:
+                                       // .NET is buggy here, it just outputs raw string, which results in invalid JSON format.
+                                       bool isString = false;
+                                       switch (text) {
+                                       case "INF":
+                                       case "-INF":
+                                       case "NaN":
+                                               isString = true;
+                                               break;
+                                       }
+                                       if (isString) {
+                                               element_kinds.Pop ();
+                                               element_kinds.Push (ElementType.String);
+                                               goto case ElementType.String;
+                                       }
+                                       break;
                                case ElementType.Boolean:
                                        break;
                                default: