-2

with node.js I run this code:

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();

and reseve via push-API JSON-Data:

[ { type: 'orderBookModify',
    data: { type: 'bid', rate: '2357.77000002', amount: '0.82956965' } } ]

now I want to work with the data, is it possible to store it into mysql or declare a variable with just a sequence of the JSON-Array?

9
  • is it possible to store it into mysql: yes. declare a variable with just a sequence of the JSON-Array not sure what you mean with a sequence of JSON-Array Commented Jun 28, 2017 at 9:26
  • I want to catch just the rate in one varibale and the amount on another Commented Jun 28, 2017 at 9:29
  • Use JSON.parse for this. Commented Jun 28, 2017 at 9:33
  • [ { type: 'orderBookModify', data: { type: 'bid', rate: '2357.77000002', amount: '0.82956965' } } ] is it a json-array or string? Commented Jun 28, 2017 at 9:35
  • Both, json is just string data in a specific format Commented Jun 28, 2017 at 9:38

1 Answer 1

0

you can use JSON.stringify to convert the JSON into string and then save it into MySQL. However, I am not sure about what you meant by a sequence of the JSON-Array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.