[["SFO",37.77493,-122.41942],["LAX",34.05223,-118.24368]]
That's my string and I want to convert it to:
arr[0] = ["SFO"....
arr[1] = ["LAX"...
EDIT
Let me clarify:
var str = '[["SFO",37.77493,-122.41942],["LAX",34.05223,-118.24368]]'
You can use JSON.parse:
JSON.parse('[["SFO",37.77493,-122.41942],["LAX",34.05223,-118.24368]]')
IE7 and below needs:
<!--[if lt IE 8.]>
<script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<![endif]-->
JSON.parse converts a string into a javascript object. Array's are objects. The string above will parse into an Array:
var array = JSON.parse('[["SFO",37.77493,-122.41942],["LAX",34.05223,-118.24368]]')
alert ( typeof array ); // object
alert ( array instanceof Array); // true
["SFO,37.77493...is already an array.var arr = eval('[["SFO",37.77493,-122.41942],["LAX",34.05223,-118.24368]]');should give you what you are looking for.arr[0] = ["SFO"...evalis evil and a terrible terrible thing to use. (bytes.com/topic/javascript/answers/145037-why-eval-evil)