使用 json-bigint 处理返回值。
json-bigint 提供了几个示例,为了彻底解决,将大数转换为字符串是比较保险的方案,因此推荐下面这个方案:
Input:
var JSONbigString = require('json-bigint')({"storeAsString": true});
var key = '{ "key": 1234567890123456789 }';
console.log('\n\nStoring the BigInt as a string, instead of a BigNumber');
var withString = JSONbigString.parse(key);
console.log('Input:', withString)
Output:
Storing the BigInt as a string, instead of a BigNumber
Input: { "key": "1234567890123456789" }