Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing JSON object properties directly and log it

I'm trying to access JSON Object properties directly and log it, here is my function :

loadProcesses(filter?){

this._postService.getAllProcess(filter)
.subscribe(
    res=> {
        this.processListe = res;
       // console.log(this.processListe.)
    }
,null,
() =>{
    console.log("get processes liste" + filter)

});

So this.processListe contain a JSON Object, and my JSON format is like this:

{"Person": {
   "id": "A256",
   "name": "GET",
   "status": "active",
   "description": "hardworking, openminded",
   ...

So it will contains exactly the same things, for example if i want to simply print the label on a console log how can i do it ??

like image 567
Anna Avatar asked Jul 01 '16 14:07

Anna


1 Answers

parse it and access the fields.

var obj = JSON.parse(filter);
obj.Person.id; 
//etc
like image 120
giannisf Avatar answered Nov 15 '22 17:11

giannisf