Hi,
I’m developing an app with Node.js and I have this code when I send a message to a server:
var msg = {
name: userName,
text: ABCD
};
var json = JSON.stringify({ type:'message', data: msg });
socket.send(json);
And here the code that receives the message from the server:
socket.addEventListener("message", function(event) {
console.log (event.data);
});
Here’s what it displays:
[B][I]
{"type":"message","data":{"name":"userName","text":"ABCD"}}[/I][/B]
I wonder if I can get it displayed like this:
userName
ABCD
I have taken the code from here: http://martinsikora.com/nodejs-and-websocket-simple-chat-tutorial
I guess the author have a function that explodes the string and grab the value accordingly, but I don’t understand what is that function.
Thanks