Hitesh Prajapati Hitesh Prajapati - 3 months ago 18
JSON Question

Remove json element

I want to remove JSON element or one whole row from JSON.

I have following JSON string:

{
"result":[
{
"FirstName": "Test1",
"LastName": "User",
},
{
"FirstName": "user",
"LastName": "user",
},
{
"FirstName": "Ropbert",
"LastName": "Jones",
},
{
"FirstName": "hitesh",
"LastName": "prajapti",
}
]
}

Answer
var json = { ... };
var key = "foo";
delete json[key]; // Removes json.foo from the dictionary.

You can use splice to remove elements from an array.

Comments