A THRIFT IDL definition uses int64. However, javascript only supports IEEE 754 double-precision floats, so int64 cannot be supported. In the following code int64 is printed as buffer
idl
Node.js is handled by node-int64, and since json.stringify supports a replacer argument, you can specify int64 in this argument:
const Int64 = require('node-int64');
function customStringifier(key, value) {
if (value instanceof Int64) {
return value.toNumber();
} else {
returnvalue; }}console.log(JSON.stringify(response, customStringifier, 2))
Copy the code
Int64 can now be processed normally:
Reference: httgp.com/deserializi…