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
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 56

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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Title # Comments Views Activity
alert on input text 2 23
Date on a table 16 34
center navbar (navigation menu) on web page 3 18
JSON decode 5 17
By this time the large percentage of day-to-day transactions have shifted to mobile banking; here are some overriding areas QAs must investigate while testing mobile banking apps.  
Ensuring effective and secure communication in the age of healthcare BYOD.
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

756 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