Forum Moderators: open

Message Too Old, No Replies

String to JSON array

         

music_man

12:50 am on Jun 10, 2007 (gmt 0)

10+ Year Member



Hi

If I have a string that looks like e.g.

[['line1',line2'],['line3','line4']]

How can I turn this into a JSON array? The split() method doesn't work...

mehh

11:00 am on Jun 10, 2007 (gmt 0)

10+ Year Member



do you mean JSON object or an array? they are two different things.
to turn it into an array (which is what i think you mean) do this

var arr
var str="[['line 1','line 2],['line 1','line 2']]";
eval("arr="+str);
alert(arr[0][0]);