I have a JSON file with labels and values and jQuery code like that:
JSON:
[
{"label":"One","value":"oneval"},
{"label":"Two","value":"twoval"},
{"label":"Three","value":"threeval"}
]
JS
$.getJSON(file.json, function (data) {
$.each(data, function (key, val) {
array[key] = { label: val.label, value: val.value };
}
}
And after that when I use console.log(array) it shows Array[], but console.log(array[0]) shows undefined. Why? How can I get data from that array?