diff --git a/Implab/JSON/JSONWriter.cs b/Implab/JSON/JSONWriter.cs --- a/Implab/JSON/JSONWriter.cs +++ b/Implab/JSON/JSONWriter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Globalization; namespace Implab.JSON { public class JSONWriter { @@ -35,7 +36,6 @@ namespace Implab.JSON { public JSONWriter(TextWriter writer) { Safe.ArgumentNotNull(writer, "writer"); - m_writer = writer; } @@ -262,7 +262,14 @@ namespace Implab.JSON { } void Write(double value) { - m_writer.Write(value); + if (double.IsNaN(value)) + Write("NaN"); + else if (double.IsNegativeInfinity(value)) + Write("-Infinity"); + else if (double.IsPositiveInfinity(value)) + Write("Infinity"); + else + m_writer.Write(value.ToString(CultureInfo.InvariantCulture)); } void OperationNotApplicable(string opName) {