I have a result of an array from JSON which may has an array inside an array. How can I parse and make it a complete Javascript Array? I set an example of a sample at here
It results:
[
{"id":"1","company":"Gaurishankar","bus_no":"JHA 12 KH 1230"},
{"id":"2","company":"Gaurishankar","bus_no":"BA 2 KH 2270"},
{"id":"3","company":"Gaurishankar","bus_no":"GA 1 KH 3018"}
]
It looks more like an JS array but when I try to use it, it is an object. I have gone through many Stackoverflow links but none help. Please bear in mind that some elememts later may bear array inside an array. So far my code is: start();
function start(){
$.ajax({
dataType: 'json',
url:"http://mylivecanvas.com/api/get_routes.php",
success: function(result){
process(result);
}
});
}
function process(object){
var obj = JSON.parse(object);
// Got this from browsing a Stackoverflow Question
var arr = $.map(obj, function(el) { return el; });
alert(arr);
}
That still returns an object, any thing I missed?