1 Star 0 Fork 0

damone/FastBinaryEncoding

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
serialization_json.js 921 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ivan Shynkarenka 提交于 2019-07-29 08:51 +08:00 . Fixed JavaScript generator
/* eslint-disable prefer-const */
'use strict'
const proto = require('../proto/proto')
// Create a new account with some orders
let account = new proto.Account(1, 'Test', proto.State.good, new proto.Balance('USD', 1000.0), new proto.Balance('EUR', 100.0))
account.orders.push(new proto.Order(1, 'EURUSD', proto.OrderSide.buy, proto.OrderType.market, 1.23456, 1000.0))
account.orders.push(new proto.Order(2, 'EURUSD', proto.OrderSide.sell, proto.OrderType.limit, 1.0, 100.0))
account.orders.push(new proto.Order(3, 'EURUSD', proto.OrderSide.buy, proto.OrderType.stop, 1.5, 10.0))
// Serialize the account to the JSON string
let json = JSON.stringify(account)
// Show the serialized JSON and its size
console.log(`JSON: ${json}`)
console.log(`JSON size: ${json.length}`)
// Deserialize the account from the JSON string
account = proto.Account.fromJSON(json)
// Show account content
console.log()
console.log(account)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/damone/FastBinaryEncoding.git
git@gitee.com:damone/FastBinaryEncoding.git
damone
FastBinaryEncoding
FastBinaryEncoding
master

搜索帮助