我正在尝试制作 JSON,但出现类型错误。错误说,无法设置未定义的属性“应用程序”。这发生在*.isFav = true
声明中。如果我删除 if 语句,它会起作用(isFavt(*)
语句)。
任何帮助将不胜感激。谢谢!
pref.userid = username;
//systems
systems = [];
for(i=0;i<system.length;i++)
{
systems[i] = new Object();
systems[i].systemid = system[i];
systems[i].apps = [];
j = 0;
$('.save label').each(function ()
{
lst = $(this).text();
console.log(systems[i]);
systems[i].apps[j] = new Object();
systems[i].apps[j].name = lst;
systems[i].apps[j].href= findHref(lst.toLowerCase().replace(/ /g,'_'));
//seq
systems[i].apps[j].seq = j;
//check for favourites
if(isFavt(lst))
systems[i].apps[j].isFav = 'true';
else
systems[i].apps[j].isFav = 'false';
//check for default
if(isDef(lst) == true)
systems[i].apps[j].isDef = 'true';
else
systems[i].apps[j].isDef = 'false';
//subapps
j = j + 1;
});
}
pref.systems = systems;
return pref;
}