Link to home
Start Free TrialLog in
Avatar of Oliver2000
Oliver2000Flag for Brazil

asked on

Get specific item from object in javascript without knowing the name of the object inside my object?

I would like to get the value of "name" from the example json object below without knowing the name of the object (123) because this could be anything and I dont know before.

{
  "123": {
    "email": "kato@firebase.com",
    "name": "Kato"
  }
}

Open in new window


I know it dont work like this but I look for something like
console.log(object[0].name);

to make it more clear.
SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Oliver2000

ASKER

Thank you guys, this was exactly what I needed.
Both solutions work fine for me but the second solution is best for me since I have some cases with more than   1 result.