how to parse json response in angular 6

54 views
Skip to first unread message

Kfir Tevet

unread,
May 20, 2019, 12:45:59 PM5/20/19
to Angular and AngularJS discussion
I manage to get this Jsons
--------------STREAM_DELIMITER
Content-Type:application/json

{"clientID": "asusD6", "packageID": 1, "httpStartTs": "asusD6_1558368943.0830119", "recordStartTs": "asusD6_1557753277"}
--------------STREAM_DELIMITER
Content-Type:application/json

{"STAUTS": "EOF"}
I want to take only the first json
How I skipped over the others?


Sander Elias

unread,
May 21, 2019, 6:24:27 AM5/21/19
to Angular and AngularJS discussion
Hi Kfir,

How are you getting this response? What code are you using to get your JSON?

Regards
Sander

Kfir Tevet

unread,
May 21, 2019, 7:04:11 AM5/21/19
to Angular and AngularJS discussion


בתאריך יום שני, 20 במאי 2019 בשעה 19:45:59 UTC+3, מאת Kfir Tevet:
this is in my angular serves
downloadFile():Observable<Pcm[]> {
let headers: HttpHeaders = new HttpHeaders()
.set('SENSOR_ID', 'asusD6')
.set('startDate', '20190513140000')
.set('endDate', '20190513140011')
.set('debugLevel', '1')
.set('Cycle', '10')
.set('Multipart', '1')
.set('Audio', '1')
.set('Accept', 'application/json')
.set('Content-Type', 'application/json');
return this.http.get<Pcm[]>(this.ROOT_URL + '/pcm_json',{headers,responseType:'json'})
}


a
 

Kfir Tevet

unread,
May 21, 2019, 7:08:06 AM5/21/19
to Angular and AngularJS discussion


בתאריך יום שלישי, 21 במאי 2019 בשעה 14:04:11 UTC+3, מאת Kfir Tevet:
 and this is in my component.ts


ondownloadFile(){
this.dataService.downloadFile().subscribe(result => {
result.forEach(r=>this.pcm.push(r));
console.log("my result is: ",this.pcm);
//const EXT = fileName.substr(fileName.lastIndexOf('.') + 1);
// saveAs(new Blob([], {type: MIME_TYPES[EXT]}), result);
});  
 

Kfir Tevet

unread,
May 21, 2019, 7:11:16 AM5/21/19
to Angular and AngularJS discussion


בתאריך יום שני, 20 במאי 2019 בשעה 19:45:59 UTC+3, מאת Kfir Tevet:
I manage to get this Jsons
Reply all
Reply to author
Forward
0 new messages