THRIFT-1245 C# JSON Protocol uses culture-dependant decimal separator for double
authorRoger Meier <roger@apache.org>
Thu, 28 Jul 2011 18:35:51 +0000 (18:35 +0000)
committerRoger Meier <roger@apache.org>
Thu, 28 Jul 2011 18:35:51 +0000 (18:35 +0000)
Patch: Nacim Rahal

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1151959 13f79535-47bb-0310-9956-ffa450edef68

lib/csharp/src/Protocol/TJSONProtocol.cs

index 5f6351f..a35fcd3 100644 (file)
@@ -23,6 +23,7 @@ using System.Text;
 using System.Collections.Generic;
 
 using Thrift.Transport;
+using System.Globalization;
 
 namespace Thrift.Protocol
 {
@@ -503,7 +504,7 @@ namespace Thrift.Protocol
                private void WriteJSONDouble(double num)
                {
                        context.Write();
-                       String str = num.ToString();
+                       String str = num.ToString(CultureInfo.InvariantCulture);
                        bool special = false;
 
                        switch (str[0])
@@ -840,7 +841,7 @@ namespace Thrift.Protocol
                        if (reader.Peek() == QUOTE[0])
                        {
                                byte[] arr = ReadJSONString(true);
-                               double dub = Double.Parse(utf8Encoding.GetString(arr));
+                               double dub = Double.Parse(utf8Encoding.GetString(arr), CultureInfo.InvariantCulture);
 
                                if (!context.EscapeNumbers() && !Double.IsNaN(dub) &&
                                        !Double.IsInfinity(dub))