标签:rom 调用 pre log buffer data 实例 object str
buf.toJSON()
const buf = Buffer.from('test');
const json = JSON.stringify(buf);
console.log(json);
// Prints: '{"type":"Buffer","data":[116,101,115,116]}'
const copy = JSON.parse(json, (key, value) => {
return value && value.type === 'Buffer' ? Buffer.from(value.data) : value;
});
console.log(copy.toString());
// Prints: 'test'
标签:rom 调用 pre log buffer data 实例 object str
原文地址:https://www.cnblogs.com/lalalagq/p/9908515.html