Be standards compliant when dealing with JSON serialization of NaN and Inf floats
Patch by dahla
This commit is contained in:
@@ -322,13 +322,16 @@ namespace LitJson
|
||||
DoValidation (Condition.Value);
|
||||
PutNewline ();
|
||||
|
||||
string str = Convert.ToString (number, number_format);
|
||||
Put (str);
|
||||
if (double.IsNaN(number) || double.IsInfinity(number))
|
||||
Put("null");
|
||||
else
|
||||
{
|
||||
string str = Convert.ToString(number, number_format);
|
||||
Put(str);
|
||||
|
||||
if (str.IndexOf ('.') == -1 &&
|
||||
str.IndexOf ('E') == -1 &&
|
||||
!double.IsNaN(number))
|
||||
writer.Write (".0");
|
||||
if (str.IndexOf('.') == -1 && str.IndexOf('E') == -1)
|
||||
writer.Write(".0");
|
||||
}
|
||||
|
||||
context.ExpectingValue = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user