In angular application I have called the API and read the Json object inconsole .But inside the Json object there is string and array.Now I have to parse the array from the object incosole.
The object I have got in console is:
{
"Drone": {
"Droneid": 1001,
"latlong": [
{
"lat": 12.989839,
"lon": 80.198822
},
{
"lat": 13.051832,
"lon": 80.194480
},
{
"lat": 13.038453,
"lon": 80.227442
},
{
"lat": 13.009018,
"lon": 80.242550
},
{
"lat": 12.976903,
"lon": 80.237056
},
{
"lat": 12.956829,
"lon": 80.193107
},
{
"lat": 12.980917,
"lon": 80.150531
},
{
"lat": 13.007680,
"lon": 80.149158
},
{
"lat": 13.043805,
"lon": 80.154651
}
]
}
}
But I have to parse latlong array from the object.
Dashboard.service.ts
mapping(token){
let httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Token ' + token
})
};
//this.http.get(this.url).subscribe(
this.http.get(environment.apiurl +'/api/data/json', httpOptions).subscribe(
(dronesdt:any)=>{
localStorage.setItem("dronesdt",JSON.stringify(dronesdt));
console.log("Drones",JSON.parse(localStorage.getItem("dronesdt")));
}
)
}
So how can I get the latlong array in console. Can anyone please help me regarding this.
console.log(dronesdt.Drone.latlong);get=>this.http.get<Drone>(...)?