AnsweredAssumed Answered

stringifyJSON turns integers to float

Question asked by BenParish on Apr 17, 2019
Latest reply on May 9, 2019 by Andy_Thompson

I am noticing a strange result when using the stringifyJSON system function. All integers are being converted to float. For example, 1 becomes 1.0 when converted. This is not the expected outcome and when using JSON.stringify I do receive integers has expected. I threw together this test script to confirm.

 

var testObj = {};

testObj.number = 1;
testObj.numStr = "1";
testObj.numFloor = Math.floor("1");
testObj.numPI = parseInt("1",10);

Process.test = stringifyJSON(testObj);
Process.test1 = JSON.stringify(testObj);

 

 

test = {"number":1.0,"numFloor":1.0,"numStr":"1","numPI":1.0}

test1 = {"number":1,"numStr":"1","numFloor":1,"numPI":1}

 

I have started to change over to using JSON.stringify, but I was curious if this was working as intended or if there is a slight bug in the stringifyJSON function. 

Outcomes