XMen
XMen

Reputation: 30248

How to convert a JSON to work as Class for creating object

Here is my JSON

var nodeclienthash={
  socket:null,
  init : function() {
    // initialize socket.io
    this.socket = new io.Socket(this.config.host, {port: this.config.port, rememberTransport: false});
 }
};

For now i want to create only two object , how should i create that ?

Upvotes: 0

Views: 259

Answers (1)

cutsoy
cutsoy

Reputation: 10251

function NodeClientHash() {
    this.socket = null;
    this.init = function() {
        this.socket = new io.Socket(this.config.host, {port: this.congig.port, rememberTransport: false});
    }
}

var client = new NodeClientHash();

Upvotes: 2

Related Questions