How to get data from this array

Hi,
I have this data:

[ {id: 1, name: ‘John Doe’ } ]

How do I get the id or name.

Thank you,

variablename[0].name

It works.

Thank you.