I have my JSON as follows
{"DATA": [{"id":11,"name":"ajax","subject":"OR","mark":63},
{"id":12,"name":"javascript","subject":"OR","mark":63},
{"id":13,"name":"jquery","subject":"OR","mark":63},
{"id":14,"name":"ajax","subject":"OR","mark":63},
{"id":15,"name":"jquery","subject":"OR","mark":63},
{"id":16,"name":"ajax","subject":"OR","mark":63},
{"id":20,"name":"ajax","subject":"OR","mark":63}],"COUNT":"120"}
Is there any good method to find out the distinct name
from this JSON
Result javascript,jquery,ajax
I can do this using following methode
var arr=[''];
var j=0;
for (var i = 0; i < varjson.DATA.length; i++) {
if($.inArray(varjson.DATA[i]["name"],arr)<0){
arr[j]=varjson.DATA[i]["name"];
j++;
}
}
Is there any better method
which gave me better performance?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…