私は以下のようにjsonオブジェクトを持っています。ここでは、 "otherIndustry"エントリとその値を削除するには、以下のコードを使用してください。jsonオブジェクトのキーと値を削除する方法?
var updatedjsonobj = delete myjsonobj['otherIndustry'];
Jsonオブジェクト固有のキーとその値を削除する方法。 以下は、 "otherIndustry"キーとその値を削除したいと思うjsonオブジェクトの例です。
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);
ここで、ログは「otherIndustry」エントリをオブジェクトから削除せずに同じオブジェクトを印刷します。
[JSONオブジェクトからキーと値のペアを削除する]の可能性のある重複を(https://stackoverflow.com/questions/24770887/remove-key-value-pair-from-json-object) –
あなたのコードはうまくいくはずです、MVCEを作成することができますhttps://stackoverflow.com/help/mcve – gurvinder372
delete myObj.other.key1; [この例に示すように](https://stackoverflow.com/questions/1219630/remove-a-json-attribute/1219633#1219633) –