This project has moved and is read-only. For the latest updates, please go here.

Bug when serializing a float

Jul 17, 2012 at 10:49 AM

if you run this code

Dim i As Single? = 5.2
Dim o1 As New JObject(New JProperty("i", i))

Dim s As String = o1.ToString(Newtonsoft.Json.Formatting.None)


the rendered JSON has i with a value of 5.199999998. this is because of the Convert.ToDouble call when writing the property (.NET might change the value when converting from single to double) .


to fix this the code should check if the value is of type single and if so call the appropriate write overload


Jul 18, 2012 at 7:29 AM

Will fix