var key = {“kay_1”:{
“sample_1”: “spmedata”
“sample_2”: “spmedata”
},
“kay_2”:{
“sample_1”: “spmedata”
“sample_2”: “spmedata”
}
}
现在我的问题是如何更新和删除“kay_2” - >“sample_1”键?
答案 0 :(得分:1)
可以同时更新两种方式
key.kay_2.sample_1 = "changed value";
key['kay_2']['sample_1'] = "changed value";
for delete is the same
delete key.kay_2.sample_1;
delete key['kay_2']['sample_1'];
答案 1 :(得分:0)
var key={"kay_1":{
"sample_1":"spmedata",
"sample_2":"spmedata",
},
"kay_2":{
"sample_1":"spmedata",
"sample_2":"spmedata",
}
}
// To update the value
key['kay_2']['sample_1'] = 'new value';
// To delete the key
delete key['kay_2']['sample_1']
答案 2 :(得分:0)
修改值try,
key.kay_2.sample_1 = "changed value";
要删除,
delete key.kay_2.sample_1