var json1={
"name":"yangliu",
"age":24,
"sex":"male",
"firend":{
"name":"pearl",
"age":24,
"sex":"male"
}
}
function appearMore(json12){
var str=JSON.stringify(json12);
var json2={}
for(var i=0;i<str.length;i++){
if(json2[str[i]]){
++json2[str[i]];
}else{
json2[str[i]]=1;
}
}
var count=0;
var maxkey;
for (var key in json2) {
if(json2[key]>count){
count=json2[key];
maxkey=key;
}else{
continue;
}
}
console.log(maxkey,":",count);
}
appearMore(json1);
解析: