JSON problema on nodeJS

Hello I am having a problem with the object in javascript passed parameter to the NodeJS.

When I create the object inside the function:

 var obj = {host: 123,
            port: 456}

and give a ws.send(obj.host) it returns me 123.

However, when I do the following:

function a(param) {
    var obj = param;
    ws.send (obj.host);
}

a({host: 123, port: 456});

it returns me undefined

The code is:

var http      = require("http");
var Sequelize = require("sequelize");
var mysql     = require('sequelize').mysql;
var WebSocketServer = require('ws').Server;

var server = http.createServer(function(request, response) {
    response.end("WS port:1337");
});

server.listen(1337, function() { });

var wss = new WebSocketServer({ server: server });

wss.on('connection', function(ws) {

ws.on('message', function(message) {
    ws.send(exec(message));
});

function exec(msg) {
    var cmd = msg.split(':')[0].toLowerCase(); //Get the first string before ':' and all cmd begin with 3 letters.
var message = '';

for(i=4; i<msg.length; i++) {
    message += msg[i];
}
console.log("Cmd type: " + cmd);

switch(cmd) { //send 'msg:' type the message after ':'.
case 'msg' :
    return message;

case 'sql' : //send to another function the object message like {host: 'x.x.x.x', port: xxxx, user...}
sql(message);
return 'res:';
break;

    default:
        return "not defined!";
    }

}   
});

When you send JSON via websocket, you should transform your string to JSON before send. This function, JSON.stringify(str), may help you. Of course, when the server receives this message, you should change it back to array.