TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kasim mohamed
1.7k
56
6.9k
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
Reply
Answers (
2
)
Filter the json object
Ok, I'm less than an hour into learning TypeScript