我正在使用 Node/Express 向 the unofficial Vine API 发出 API 请求.
GET https://api.vineapp.com/users/search/
路由返回的数据在解析时发生变化。
我的代码如下:
request({ url: 'https://api.vineapp.com/users/search/' + username }, function (error, response, body) {
if (error) throw new Error(error);
console.log(typeof body,'UNPARSED BODY:', body);
body = JSON.parse(body);
console.log(typeof body,'PARSED BODY:', JSON.stringify(body, null, 2));
cb(null, body)
});
这是返回: data.records.userId 在解析时发生变化。
为什么会这样?我在这里错过了什么吗?他们为什么要这样做?
最佳答案
对于 JSON 解析器来说这个数字太高了
关于 javascript 中最高可能值的信息:
What is JavaScript's highest integer value that a Number can go to without losing precision?
这里提供了一个解决方案:
node.js is there any proper way to parse JSON with large numbers? (long, bigint, int64)
关于javascript - JSON.parse( ) 的数值变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38070943/