javascript - JSON.parse( ) 的数值变化

标签 javascript json node.js parsing vine

我正在使用 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)
});

这是返回: enter image description here 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/

相关文章:

node.js - 如何 stub 文件中未声明的对象的实例

javascript - Angular 、动态指令加载和事件管理

javascript - Kendo Treeview : Can you edit a single dataitem without full tree update?

javascript - 删除 sql 或 javascript 循环中的层次结构行

C# ASP.net- 接收 WebClient 发布到服务器并读取值

mysql - 将所有多行 LONGTEXT 列转换为 JSON 列

javascript - 更新 mongodb 中的集合

javascript - Jquery UI 可排序多选

javascript - Aurelia 依赖注入(inject)中的容器是什么

PHP:JSON 或 XML 解析器更快吗?