I have a JSON below :
{
"sports": [
{ "id": 1, "name": "Soccer" },
{ "id": 2, "name": "Basketball" }
]
}
How I can read the id and the name in typeScript ? Currently I use
let result = this.dataService.getJSON()
public getJSON(): Observable<any> {
return this.http.get('./assets/json/data.json');
}
But I have a error message
map is not a function
I don't know How I can parse the JSON,
I would like have this result.
[
{ "id": 1, "name": "Soccer" },
{ "id": 2, "name": "Basketball" }
]
Thank for your help.