I am using Node.js and the built-in JSON object to stringify a JSON object. In the object is
{
weight : 1.0
}
However when I stringify and write to a file the output is weight : 1.
As noted in this answer to a similar question, and on this MSDN page:
There is no such thing as an integer in JavaScript. Numbers in JavaScript are "double-precision 64-bit format IEEE 754 values".
Open up your web browser's console and type 1.0. You'll see 1 printed out. All numbers in JavaScript are floating point numbers, so your serializer simply chose to leave off unnecessary precision.
Actually yours is not an issue , 1 == 1.0 == 1.00 in Javascript and if you have a float value like 1.55 then stringify gives you the same 1.55 not 1.. Even then if you want 1.0 to be written , change the value into string
I mean Enclose the value in double quotes
{
weight : "1.0"
}