I am trying to create objects sent as streams over the wire but I am
no expert in javascript, can anybody lend me a hand please?
// this works, no problem at all
client = {name:'John Doe', age:35};
alert(client.na me);
// this doesn't
stream = "{name:'Jan e Doe', age:32}";
person = eval(stream);
alert(person.na me);
The whole idea is to request data to a back-end, then the server will
produce streams in the javascript format that will be used to create
objects on the client side.
The question is: how to use the stream as object initializer? I tried
'eval' but didn't work, maybe I'm doing it wrong. Any other ideas?
Thanks in advance
no expert in javascript, can anybody lend me a hand please?
// this works, no problem at all
client = {name:'John Doe', age:35};
alert(client.na me);
// this doesn't
stream = "{name:'Jan e Doe', age:32}";
person = eval(stream);
alert(person.na me);
The whole idea is to request data to a back-end, then the server will
produce streams in the javascript format that will be used to create
objects on the client side.
The question is: how to use the stream as object initializer? I tried
'eval' but didn't work, maybe I'm doing it wrong. Any other ideas?
Thanks in advance
Comment