私は、キー "errMsg"を持つ子を削除したいjsonオブジェクトを持っています。JSONオブジェクト内でループして特定の子を削除します
input JSON : {"info":[{"errorMsg":"Unable to find Vendor ","c2v":"some text"},{"errorMsg":"Unable to find Vendor ","c2v":"Some text"},{"errorMsg":"Unable to find Vendor","c2v":" Some text"},{"id":"1038578481","ven":"DEMOMA","c2v":" Some text"}]}
結果私は、JSONには "errorMsg"が含まれていない必要があります。
output JSON i want : {"info":[{"id":"1038578481","ven":"DEMOMA","c2v":" Some text"}]}
私は私のために働いていない
jsonKeyInfo = stringToJson(form.response);
for(var i in jsonKeyInfo.info){
if(jsonKeyInfo.info[i].errorMsg){
errMsg = jsonKeyInfo.info[i].errorMsg;
jsonKeyInfo.info.splice(i,1);
err++;
// delete jsonKeyInfo.info[i];
}
}
を使用するコード。
非常に良い答えを楽しむあなたのコンソールでこれを試してみてください。 – mohammad
私はエラーが定義されていません、また、このシンボルが何を意味するのかを確認できますか?i.errorMsg –
彼らは矢印関数として知られています。詳細は https://developer.mozilla.org/ja/を参照してください。 docs/Web/JavaScript/Reference/Functions/Arrow_functions –