I have a Json having few data with ID null, what i want is to remove the items having id null. Please suggest the best approach.
so in itemProperty i want to remove two items where id is null
{
itemProperties :
{
itemProperty: [
{
id:"23",
name: "asd"
},
{
id:"232",
name: "asd1"
},
{
id:null,
name: "asd2"
},
{
id:"2932",
name: "asd3"
},
{
id:null,
name: "asd4"
}
]} }
4
Answers
you can use the
.filter
method on a js array as shown below.this will return the filtered array with only the items that pass the test.
Here is data in the scaffold in the object! But I update the data format
You can try this,
O/P :