09月22日, 2014 2030次
const fs = require('fs') const protobuf = require('protocol-buffers'); //const schema = protobuf(fs.readFileSync(__dirname + '/config.proto', 'utf-8')); protfilestr = `message Column { required int32 id = 1; required string name = 2; required float price = 3; }` const schema = protobuf(protfilestr); console.log(schema); op_obj={id: 1, name: "Node-----", price: 80.4} const buffer = schema.Column.encode(op_obj) console.log(buffer); const deobj = schema.Column.decode(buffer); console.log(deobj);
暂无留言,赶快评论吧