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

Posted on 2016-09-01
Last Modified: 2016-09-02
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": "",
    "name": "Kato"

Open in new window

I know it dont work like this but I look for something like

to make it more clear.
Question by:Oliver2000
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 22

Assisted Solution

by:Kim Walker
Kim Walker earned 250 total points
ID: 41780991
Is there always only one child object in the JSON object? If so, you could use
object = {
  "123": {
    "email": "",
    "name": "Kato"
for (var i in object) {

Open in new window

LVL 57

Accepted Solution

Julian Hansen earned 250 total points
ID: 41781359
To get the first (or Nth if you desire) object from an object you can use Object.keys()

In your case for the first object use index 0
var data = {
  "123": {
    "email": "",
    "name": "Kato"

Open in new window


Author Closing Comment

ID: 41781553
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.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ransomware is a growing menace to anyone using a computer or mobile device. Here are answers to some common questions about this vicious new form of malware.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question