我有两个JSON字符串化对象,
var first='{"AdmissionId":254625,"PhysicianId3":null,"VerbalStartOfCareDate":"","PhysicianId2":null,"LatestStatusCode":"A01","ReferralSource":97664,"PhysicianId1":97670,"$id":"2","LatestAdminSetId":90,"LastModified":"2015-03-16T10:13:55.827","AdmitDate":"2015-03-01T00:00:00","TeamId":153,"ProspectAdmitDate":null,"TerminationDate":null,"PatientId":154112,"PatientStatus":[{"Notes":null,"PpsTherapyVisits":null,"SyncEpisodes":null,"StatusCode":"A01","StatusId":0,"PpsEpisodeNo":1,"StatusEndDate":null,"PrimaryDiagnosisId":870428,"Sequence":2,"PpsAssessDate":null,"PatientId":154112,"Acuity":"Pend","SyncStatus":4,"LastModified":null,"BranchId":null,"PpsAssessRfa":null,"PrintDischargeSummary":null,"OasisMatchingKey":null,"PpsScicOverride":null,"PpsKnownLupa":null,"DataSetId":26,"AdminSetId":90,"MsaCode":"50094","GenerateFinalClaimOnly":null,"PpsEpisodeNoModified":"N","AssociatedFacilityRoleId":null,"ClassEndDate":null,"PpsHippsCode":null,"PpsHippsValidity":null,"PatientClass":"HH","ClientId":0,"PpsAssessmentId":null,"StatusTime":null,"HpcanysCareLocation":null,"PpsHhrgId":null,"EpsHhrgId":null,"Id":0,"$id":"3","StatusDate":"2015-08-17T00:00:00","AdmissionId":254625,"PpsNrsSeverityId":null,"AssociatedFacilityId":null}],"CaregiverCode":"SP","ReferralSourceRoleId":33149,"ClinicalSetId":93,"PatientAdmissionCtiDef":null,"Id":0,"SnfIndicator":null,"ClientId":0,"AdmissionCode":null,"ProspectTermDate":null,"SyncStatus":2,"Sequence":1}';
var second = '{"AdmissionId":254625,"PhysicianId3":null,"VerbalStartOfCareDate":null,"PhysicianId2":null,"LatestStatusCode":"A01","ReferralSource":97664,"PhysicianId1":97670,"$id":"2","LatestAdminSetId":90,"LastModified":"2015-03-16T10:13:55.827","AdmitDate":"2015-03-01T00:00:00","TeamId":153,"ProspectAdmitDate":null,"TerminationDate":null,"PatientId":154112,"PatientStatus":[{"Notes":null,"PpsTherapyVisits":null,"SyncEpisodes":null,"StatusCode":"A01","StatusId":802577,"PpsEpisodeNo":1,"StatusEndDate":null,"PrimaryDiagnosisId":870428,"Sequence":1,"PpsAssessDate":null,"PatientId":154112,"Acuity":"Pend","SyncStatus":2,"LastModified":"2015-03-16T10:11:26.857","BranchId":null,"PpsAssessRfa":null,"PrintDischargeSummary":null,"OasisMatchingKey":null,"PpsScicOverride":null,"PpsKnownLupa":null,"DataSetId":26,"AdminSetId":90,"MsaCode":"50094","GenerateFinalClaimOnly":null,"PpsEpisodeNoModified":"N","AssociatedFacilityRoleId":null,"ClassEndDate":null,"PpsHippsCode":null,"PpsHippsValidity":null,"PatientClass":"HH","ClientId":0,"PpsAssessmentId":null,"StatusTime":null,"HpcanysCareLocation":null,"PpsHhrgId":null,"EpsHhrgId":null,"Id":0,"$id":"3","StatusDate":"2015-03-01T00:00:00","AdmissionId":254625,"PpsNrsSeverityId":null,"AssociatedFacilityId":null}],"CaregiverCode":"SP","ReferralSourceRoleId":33149,"ClinicalSetId":93,"PatientAdmissionCtiDef":null,"Id":0,"SnfIndicator":null,"ClientId":0,"AdmissionCode":null,"ProspectTermDate":null,"SyncStatus":2,"Sequence":1}';
我需要从上面提到的JSON对象中删除以下属性,并且应该比较它的结果:
我使用了下划线的_.omit()功能,它只删除了外部集合属性但是它无法删除内部集合属性
例如:上面JSON中的PatientStatus.StatusId
我也尝试使用它正在运行的delete
关键字javascript,但有没有更好的方法呢?