I have a large list of objects inside JSON like this:
var data = {
4eae1aa12efa83745d00000b: {
location: "office",
latLong: [
40.7069546, -74.0094471
],
},
4eae1aa12efa83745d000000: {
location: "home",
latLong: [
42.3584308, -71.0597732
]
}
};
Where the 4eae1aa12efa83745d00000b style key is random. How do I iterate through the JSON to print the location and latLong array of each nested JSON object?
I tried:
$.each(data, function() {
$.each(this, function() {
console.log(this.location);
});
});
but that doesn’t return anything
You should look up the $.map function to translate the items in your object/array – Go for something like this:
I believe that’s what you’re after anyway.