kasim mohamed

kasim mohamed

  • 1.7k
  • 57
  • 7k

Remove object from JSON which is matched into Netsted Object

Sep 12 2020 9:51 PM
i have a list of object like below
listobj = [
{id:101, name:'AAA'},
{id:102, name:'BBB'},
{id:103, name:'CCC'},
{id:104, name:'DDD'},
{id:105, name:'EEE'},
{id:106, name:'FFF'},
{id:107, name:'GGG'},
{id:108, name:'HHH'},
{id:109, name:'III'},
{id:110, name:'JJJ'},
];
and also nested object like below
nestobj = [
{ id:101, name: 'AAA', parentid:0, level: 'L1',
children: [
{ id: 102, name: 'BBB', parentid:101, level: 'L2'},
{ id: 103, name: 'CCC', parentid:101, level: 'L2',
children: [{id: 104, name: 'DDD', parentid:103, level: 'L3'}]
}
]
},
{ id:105, name: 'EEE', parentid:0, level: 'L1',
children: [{ id: 106, name: 'FFF', parentid:105, level: 'L2'}]
}
];
what i want is i need to remove all the object from 'listobj' which the 'id' is matching into 'nestobj' id.
the expected result would be like below
resultobj = [
{id:107, name:'GGG'},
{id:108, name:'HHH'},
{id:109, name:'III'},
{id:110, name:'JJJ'}
];
 
Thanks 

Answers (2)