var msg = JSON.parse(json)

On Sat, Jul 7, 2012 at 7:08 PM, Ket <kettin...@gmail.com> wrote:
> Hi I have this code when I send message:
>
> 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:
>
> socket.addEventListener("message", function(event) {
>      console.log (event.data);
> });
>
> Here's what it displays:
>
> {"type":"message","data":{"name":"userName","text":"ABCD"}}
>
> How do I make it display like this:
>
> userName
> ABCD
>
> Thanks
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to