I have a json object as shown below. where i want to delete the "otherIndustry" entry and its value by using below code which doesn't worked.
var updatedjsonobj = delete myjsonobj['otherIndustry'];
How to remove Json object specific key and its value. Below is my example json object where i want to remove "otherIndustry" key and its value.
var myjsonobj = {
"employeeid": "160915848",
"firstName": "tet",
"lastName": "test",
"email": "[email protected]",
"country": "Brasil",
"currentIndustry": "aaaaaaaaaaaaa",
"otherIndustry": "aaaaaaaaaaaaa",
"currentOrganization": "test",
"salary": "1234567"
};
delete myjsonobj ['otherIndustry'];
console.log(myjsonobj);
where the log still prints the same object without removing 'otherIndustry' entry from the object.
var myjsonobj ={ "employeeid": "160915848", "firstName": "tet", "lastName": "test", "email": "[email protected]", "country": "Brasil", "currentIndustry": "aaaaaaaaaaaaa", "otherIndustry": "aaaaaaaaaaaaa", "currentOrganization": "test", "salary": "1234567" }; delete myjsonobj ['otherIndustry']; console.log(myjsonobj );
still prints the same object. :( – Wetypeof myjsonobj
and tell me what you've received. – Balkanizemyjsonobj=JSON.parse(myjsonobj); delete myjsonobj['otherIndustry']
– Balkanizemyjsonobj=JSON.stringify(myjsonobj)
– Balkanize