my explorations into jquery are proving a little frustrating.
I am receiving the following Json back from the server.
{"status":"ok",
"0":{"ID":"1","location":"location info"},
"1":{"ID":"2","location":"location info"},
"2":{"ID":"3","location":"location info"},
...etc
});
I need to put all the objects except the status into an array.
I achieved this in AS3 as follows, but don’t seem to be able to get any where near using jquery.
public function ResultToArray(jsonString:String):Array
{
var jObj:Object = JSON.decode(jsonString);
var objects:Array = [];
for each(var obj:Object in jObj)
{
if(obj is String)break;
objects.push(obj);
}
return objects;
}
I would like to put each of the objects in an array.
The following only loops over one object.
$(data).each(function(index)
{
alert(data[index]["location"])
});
Please pardon my ignorance.
If I could receive any advice It’d be much appreciated.
Possibly you could check
(typeof o[c] == 'object')if you don’t want to check for ‘status’.