IT Process Automation

Expand all | Collapse all

stringifyJSON turns integers to float

Jump to Best Answer
  • 1.  stringifyJSON turns integers to float

    Posted 04-17-2019 11:14 AM

    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. 



  • 2.  Re: stringifyJSON turns integers to float
    Best Answer

    Posted 05-09-2019 08:45 AM

    I am not finding any details on the output of this function, but I did run a test internally and I see the same results.  I would suggest opening a support case on this.  Then we can request information from level 2 if necessary.