-3
我有一個對象填充數據。我想編輯我的JSON對象
我要添加,刪除,移動和下移以及編輯該數據。
這裏是我的對象的示例:
this.questions =
{
"testQS":[
{
"quote": "Quote 888",
"type": "something",
}, {
"quote": "Quote 999",
"type": "something2,
}
...
我已經找到了如何做到這一點。
要刪除一個項目使用:
this.questions.testQS.splice(index, 1);
要交換的元素中使用這樣的事情:
const temp = this.questions.testQS[index];
this.questions.testQS[index] = this.questions.testQS[index-1];
this.questions.testQS[index-1] = temp;
所以,我想在Typescript中編輯這個對象 –
JavaScript對象(你有什麼)和它在JavaScript Object Notation(JSON,你沒有)中的字符串表示有區別。 – crashmstr