jsonファイル
{"people":[{"Name":"Ray Parker","Email":"luctus.et.ultrices@natoque.ca","State":"Wyoming","Country":"Tuvalu","Martial Status":"Divorced","Department Name":"Tech Support","Company Name":"Borland","Title":"Dr.","Gender":"Male"},
{"Name":"Davis Hooper","Email":"et.libero.Proin@egetvarius.org","State":"Nunavut","Country":"Bangladesh","Martial Status":"Divorced","Department Name":"Public Relations","Company Name":"Cakewalk","Title":"Mr.","Gender":"Female"}, ...... and so on
私は、Country の個別の値とその国の人数を使用して、これから json オブジェクトを作成するのが好きです。
コードを試してみました
$(document).ready(function() {
var data = $.ajax({
url: "Data_prop.json",
dataType: "json",
async: false
}).responseText;
var unique = {};
var param = "Country"
$.each(data.people, function() {
if (!unique[this[param]])
unique[this[param]] = [];
unique[this[param]].push(this);
});
for(var d in unique) {
alert(d);
}
});
コンソールに表示されたエラー
TypeError: a is undefined
https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
Line 2
これを行う方法を知っている人はいますか?