After getting the background data, JSON.parse () finds that the data is inconsistent with the original. How to solve it?

the JSON obtained from the background is in the form of a string:

{"createTime":1528773852384,"dealPrice":"0.000000","id":19144683686985728,"isView":true,"totalPrice":"1.000000","waitProduct":"1.000000"}

the id of this data is 19144683686985728, but after JSON.parse (), it is found that the data has been changed

.
{
    "createTime": 1528773852384,
    "dealPrice": "0.000000",
    "id": 19144683686985730,
    "isView": true,
    "totalPrice": "1.000000",
    "waitProduct": "1.000000"
}

after id, the two digits have been changed from 28 to 30. How to make it parse and solve normally? it is best to solve it at the front end

.
Mar.19,2021

this is not caused by parsing. Grab the package and see if the data passed is incorrect.


the largest integer that can be accurately expressed in JS is Math.pow (2,53), which is 9007199254740992 in decimal system. If you express a number in this way, you may lose its accuracy.
it is recommended that you ask the backend id to pass a string


JSON.parse . It is impossible to use it if it is greater than the safe value Number.MAX_SAFE_INTEGER (2 ^ 53-1), and the precision is not enough to express it.
return string in the background.


var value = json.match (/ "id": (d +) /) [1];
var data = JSON.parse (json);
data.id = value;


returns the string "id": "19144683686985728"

Menu