关于javascript:js-json-parse-bigint-丢失精度的问题

3次阅读

共计 289 个字符,预计需要花费 1 分钟才能阅读完成。

js json parse bigint 失落精度的问题

1. 获取原始数据
2. 应用正则替换 bigint 为 string
3.JSON.parse()

const json = '{"smallNumber": 1,"bigNumber": 9007199254740999}';
console.log(regexbig(json));
function regexbig(input:string) {// const re1 = input.replace(/:s*([0-9]{15,})s*(,?)/g, ':"$1"$2')
 //  console.log(re1); return JSON.parse(input);
}
正文完
 0