Copy link to clipboard
Copied
I am opening a socket ant getting a doc with json over the net. heres a code snipet.
| response | = conn.read(); | ||||
| lines | = response.split(/\n/); | ||||
| var j | = lines[lines.length-1]; | ||||
| conn.close(); | |||||
| j = eval(j); |
(why the hell I cant paste into here without it becoming a table I'll never know)
if I chane the last line to alert(j) it shows me the correct json string. When I do eval(j) I get the message "unable to execute script at line 1 ; expected
am I missing something here?
Just for fun, try this:
eval("(" + j + ")");
Dan
Copy link to clipboard
Copied
Just for fun, try this:
eval("(" + j + ")");
Dan
Copy link to clipboard
Copied
holy sh*t, I can't beleive that actually works...can you explain why (just curious)
Mike Cardeiro
Copy link to clipboard
Copied
Just Google "javascript eval json". I think the best answer is the one from stackoverflow (fourth from the top). Read the top few responses.
Dan
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more