我从JSON数据中反序列化了以下对象
[{
"EmployeeNumber": "169",
"EmployeeNumberError": "",
"EmployeeFirstName": "saj"
}, {
"EmployeeNumber": "169",
"EmployeeNumberError": "",
"EmployeeFirstName": "Carlton"
}, {
"EmployeeNumber": "1002",
"EmployeeNumberError": "",
"EmployeeFirstName": "Stanley"
}]

我希望得到所有重复的' EmployeeNumber'从使用javascript或jQuery的对象。任何人都可以帮助我吗?
答案 0 :(得分:0)
试试这个
$(document).ready(function() {
var v = [{
"EmployeeNumber": "169",
"EmployeeNumberError": "",
"EmployeeFirstName": "saj"
}, {
"EmployeeNumber": "169",
"EmployeeNumberError": "",
"EmployeeFirstName": "Carlton"
}, {
"EmployeeNumber": "1002",
"EmployeeNumberError": "",
"EmployeeFirstName": "Stanley"
}];
var a = [];
for (x = 0; x < v.length; x++) {
for (y = 0; y < v.length; y++) {
if (v[x].EmployeeNumber == v[y].EmployeeNumber) {
a.push(v[x].EmployeeNumber)
}
}
}
a = jQuery.unique(a);
alert(a[1]);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>