JSON.parse()上的数值更改
我使用Node / Express来向非官方的Vine API发送API请求。
GET https://api.vineapp.com/users/search/
路由在parsing时返回的数据。
我的代码如下:
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在parsing时发生变化。
为什么会发生? 我在这里错过了什么? 他们为什么要那样做?
这个数字对于JSONparsing器来说太高了
有关javascript中可能的最高值的信息:
什么是数字可以达到的JavaScript的最高整数值,而不会失去精度?
这里提供了一个解决scheme:
node.js是否有任何正确的方法来parsing大数字的JSON? (long,bigint,int64)