从angularjs中的JSON数组中删除重复的对象

时间:2016-07-14 09:37:20

标签: angularjs json

我从服务中收到以下json对象:

[{
    "EmployeeID": 8513,
    "EmployeeName": "Afridi,Masoom Khan",
    "EmployeeMailID": "Masoom.Afridi@COELAB.COM",
    "Vertical": "INFRA",
    "ProjectID": "000000000002105",
    "ProjectDescription": "ITH - Data Center Impl.",
    "PeriodEndDate": "19-JUN-16",
    "TimeSheetID": "0001612322",
    "CreationDate": "27-JUN-16",
    "SubmissionDate": "27-JUN-16",
    "TimeSheetStatus": "NA",
    "Approver": "MISHRA,BISWAJIT",
    "ApproverMailID": "biswajit.mishra@COELAB.COM"
}, {
    "EmployeeID": 8513,
    "EmployeeName": "Afridi,Masoom Khan",
    "EmployeeMailID": "Masoom.Afridi@COELAB.COM",
    "Vertical": "INFRA",
    "ProjectID": "000000000002105",
    "ProjectDescription": "ITH - Data Center Impl.",
    "PeriodEndDate": "26-JUN-16",
    "TimeSheetID": "0001612324",
    "CreationDate": "27-JUN-16",
    "SubmissionDate": "27-JUN-16",
    "TimeSheetStatus": "NA",
    "Approver": "MISHRA,BISWAJIT",
    "ApproverMailID": "biswajit.mishra@COELAB.COM"
}]

我想将给定的对象转换为以下json格式:

[{
    "ProjectID": "000000000002105",
    "ProjectDescription": "ITH - Data Center Impl.",
    "Approver": "MISHRA,BISWAJIT",
    "ApproverMailID": "biswajit.mishra@COELAB.COM",
    "Employee": {
        "EmployeeID": 8513,
        "EmployeeName": "Afridi,Masoom Khan",
        "EmployeeMailID": "Masoom.Afridi@COELAB.COM",
        "Vertical": "INFRA",
        "TimeSheet": [{
            "PeriodEndDate": "26-JUN-16",
            "TimeSheetID": "0001612324",
            "CreationDate": "27-JUN-16",
            "SubmissionDate": "27-JUN-16",
            "TimeSheetStatus": "NA"
        }, {
            "PeriodEndDate": "19-JUN-16",
            "TimeSheetID": "0001612322",
            "CreationDate": "27-JUN-16",
            "SubmissionDate": "27-JUN-16",
            "TimeSheetStatus": "NA"
        }]
    }
}]
你能帮忙吗?

0 个答案:

没有答案