Sails.js,获取请求params一个json对象

我在Sails.js中使用套接字

以下是一个示例客户端代码:

socket.get('/message/send', {from: userId, to: recepientId, content: textMessage}); 

这就是我如何获取控制器(服务器)中的数据:

  var to = req.param('to'); var from = req.param('from'); var content = req.param('message'); 

现在,因为我发送的数据作为JSON,我想把它作为一个JSON对象。 所以消息最终是一个模型,我想直接使用json对象将数据存储在数据库中。

我使用socket.emit('channel',{userId: "someId"})时,类似的东西对我来说是有效的。所以我在socket.on('channel', function(userJsonObject){});接收到一个JSON对象socket.on('channel', function(userJsonObject){});

那么当我使用socket.get()时,如何得到类似的JSON对象

不知道为什么这么重要,但是像这样

 socket.get('/message/send', { message: JSON.stringify({from: userId, to: recepientId, content: textMessage}) }); 

应该pipe用。