JSON Accessing in Ionic 3

Hello There

I have a json data which is like this:-

"0": {
    "id": 1,
    "name": "intra",
    "created_at": "2018-02-23 09:02:07",
    "updated_at": "2018-02-23 09:02:07"
},
"1": {
    "id": 2,
    "name": "Protein Blends",
    "created_at": "2018-02-23 09:02:33",
    "updated_at": "2018-02-23 09:02:33"
},
"2": {
    "id": 3,
    "name": "Protein Blends",
    "created_at": "2018-02-23 09:03:36",
    "updated_at": "2018-02-23 09:03:36"
}

}

i got this data via api but in html i am not able to travese the as i want to print the name only

If by “traverse” you mean ngFor, you’ll need to convert this object into an array.

Hey thanks for the reply. but not able to convert in to array. can you please let me know how it works.
@rapropos

If you are familiar with underscore library, you can use the below code to get only values in array and traverse using ngFor

_.values({one: 1, two: 2, three: 3});
=> [1, 2, 3]
1 Like