JSON to javaScript array

var locations = [];
$.each(JSONObject.results.bindings, function(i, obj) {
    locations.push([obj.place.value, obj.lat.value, obj.long.value, obj.page.value]);
});

Iterate through bindings, and put the properties place.value, lat.value, long.value and page.value from each element into an array, then add this array to locations.

Your current code uses object twice, as well as property, thus overwriting those variables. You should use unique variable names in nested loops to be able to distinguish between them.

Leave a Comment