In my angular application, I have made a call to the API and retrieved a JSON object in the console. However, within this JSON object, there are both strings and arrays. My task now is to extract and parse the array from the object in the console.
The JSON object displayed in the console is as follows:
{
"Drone": {
"Droneid": 1001,
"latlong": [
{
"lat": 12.989839,
"lon": 80.198822
},
{...more coordinates here...}
]
}
}
My goal is to extract the "latlong" array from this JSON 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")));
}
)
}
How can I specifically access and retrieve the "latlong" array in the console? Any assistance on this matter would be greatly appreciated.