{ "id": "173106", "key": "TIMOB-26974", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2019-06-07T22:28:23.000+0000", "created": "2019-03-09T21:42:48.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-06-07T22:28:23.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "I'm trying to debug the reson why JSON.Parse() is adding 0000001 at the end of some int numbers.\r\n\r\nMy raw output form the API looks like\r\n\r\nRawInput\r\n{\"Weight\":10.9,\"BodyFatPercentage\":20.5}\r\n\r\n{\"Weight\":10.99,\"BodyFatPercentage\":50.5}\r\n\r\nBut when I use JSON.parse(this.responseText); I end up with JSON object that looks like this. And as you can see number 70,9 - 80,9 and 90,9 get somehow converted. And only numbers in 70,80 and 90\r\n\r\nParsed object\r\n{\r\nBodyFatPercentage = 20.5;\r\nWeight=\"10.90000000000001\";\r\n}\r\n\r\n{\r\nBodyFatPercentage = 80.5;\r\nWeight=\"10.98999999999999\";\r\n}\r\n\r\nAs you can see the parsed JSON objects property \"Weight\" is now a string, where BodyFatPercentage is still int. And if the number is .99 we get .989999\r\n\r\n", "attachment": [], "flagged": false, "summary": "JSON.Parse() is converting int to string when number is .9", "creator": { "name": "lukic", "key": "lukic", "displayName": "Srdjan Lukic-Bardak", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "lukic", "key": "lukic", "displayName": "Srdjan Lukic-Bardak", "active": true, "timeZone": "Europe/Berlin" }, "environment": "iOS Simulator\r\nSDK 7.5.0.GA", "comment": { "comments": [ { "id": "446657", "author": { "name": "lukic", "key": "lukic", "displayName": "Srdjan Lukic-Bardak", "active": true, "timeZone": "Europe/Berlin" }, "body": "You can try it by doing this :\r\n\r\n var obj = JSON.parse('{ \"Id\": 52, \"ElementId\": \"5e9e81ca-3980-4bf9-b7aa-bd3baa2d466c\", \"Chest\": 60.9, \"Waist\": 70.9, \"Hips\": 80.9, \"Thigh\": 90.99, \"Calf\": 100.9 }')\r\n\r\n Ti.API.log(obj);", "updateAuthor": { "name": "lukic", "key": "lukic", "displayName": "Srdjan Lukic-Bardak", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-03-09T21:53:59.000+0000", "updated": "2019-03-09T21:53:59.000+0000" }, { "id": "448159", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is expected, you are running into a precision error. None of the numbers are integers, integers are whole numbers. The numbers are doubles and there's not enough accuracy to store them correctly.", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-05-02T23:32:12.000+0000", "updated": "2019-05-02T23:32:12.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }