如何更新和删除JSON中的嵌套项目?

时间:2020-06-09 20:54:48

标签: angular typescript http

如何使用成角度的HttpClient请求以这种格式从.json文件添加,更新和删除testDrives项目:

{
    "cars": ["BMW", "Audi"],
    "testDrives": [
        {
            "start": "2020-06-03T11:00:00.000Z",
            "end": "2020-06-03T12:00:00.000Z",
            "name": "BMW",
        },
        {
            "start": "2020-06-03T14:00:00.000Z",
            "end": "2020-06-03T15:30:00.000Z",
            "name": "Audi",
        }
     ]
}

我尝试使用标头,斜杠和id,但似乎不起作用:

this.http
      .get(this.file+'testDrives[0]').subscribe(res => console.log(res));

0 个答案:

没有答案