【发布时间】:2017-12-01 14:03:23
【问题描述】:
使用 node.js 我运行以下代码:
var autobahn = require('autobahn');
var wsuri = "wss://api.poloniex.com";
var connection = new autobahn.Connection({
url: wsuri,
realm: "realm1"
});
connection.onopen = function (session) {
function marketEvent (args,kwargs) {
console.log(args);
}
function tickerEvent (args,kwargs) {
console.log(args);
}
function trollboxEvent (args,kwargs) {
console.log(args);
}
session.subscribe('USDT_BTC', marketEvent);
}
connection.onclose = function () {
console.log("Websocket connection closed");
}
connection.open();
并通过 push-API JSON-Data 恢复:
[ { type: 'orderBookModify',
data: { type: 'bid', rate: '2357.77000002', amount: '0.82956965' } } ]
现在我想处理数据,是否可以将其存储到 mysql 或仅使用 JSON-Array 序列声明一个变量?
【问题讨论】:
-
is it possible to store it into mysql:是的。declare a variable with just a sequence of the JSON-Array不确定你对a sequence of JSON-Array的意思 -
我只想获取一个变量的汇率和另一个变量的金额
-
为此使用 JSON.parse。
-
[ { type: 'orderBookModify', data: { type: 'bid', rate: '2357.77000002', amount: '0.82956965' } } ] 是json数组还是字符串?跨度>
-
两者,json只是特定格式的字符串数据
标签: javascript json node.js websocket push-api