/* eslint-disable prefer-const */'use strict'const proto = require('../proto/proto')// Create a new account with some orderslet 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 stringlet json = JSON.stringify(account)// Show the serialized JSON and its sizeconsole.log(`JSON: ${json}`)console.log(`JSON size: ${json.length}`)// Deserialize the account from the JSON stringaccount = proto.Account.fromJSON(json)// Show account contentconsole.log()console.log(account)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。