Skip to content

Commit 564c61f

Browse files
imerovingianJacksonTian
authored andcommitted
1.添加json-bigint库 (#92)
2.解决JSON.parse 之后精度就丢失问题
1 parent 5fd18ab commit 564c61f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/api_common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// 本文件用于wechat API,基础文件,主要用于Token的处理和mixin机制
44
const httpx = require('httpx');
55
const liburl = require('url');
6+
const JSONbig = require('json-bigint');
67
const {
78
replaceJSONCtlChars
89
} = require('./util');
@@ -129,7 +130,7 @@ class API {
129130
var data;
130131
var origin = buffer.toString();
131132
try {
132-
data = JSON.parse(replaceJSONCtlChars(origin));
133+
data = JSONbig.parse(replaceJSONCtlChars(origin));
133134
} catch (ex) {
134135
let err = new Error('JSON.parse error. buffer is ' + origin);
135136
err.name = 'WeChatAPIError';

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"dependencies": {
1919
"formstream": ">=0.0.8",
20-
"httpx": "^2.1.1"
20+
"httpx": "^2.1.1",
21+
"json-bigint": "^0.2.3"
2122
},
2223
"devDependencies": {
2324
"coveralls": "*",

0 commit comments

Comments
 (0)