JavaScript Get 1st Value in JSON?

How do I return the key (1st value) in each line  (Both ways as  JSON Array and  Standard) ?
	
	var botwts = [
	    {"1234567890" : true,
		"1234567891" : true,
		"1234567892" : true,
		"1234567893" : true}
	 
	]

///or 

	var botwts = [
	    {"1234567890" : true},
		{"1234567891" : true},
		{"1234567892" : true},
		{"1234567893" : true}
	 
	]
	
	
	for (var i = 0; i < botwts.length; i++) {

			console.log("==> Value from DL is : "+ botwts[i][0]);
	
	}

Open in new window

Want to only get the key returned for each line? Excuse me if my terminology is off. I still get confused as to what is what!
894359Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
	var botwts = [
	    {"1234567890" : true,
		"1234567891" : true,
		"1234567892" : true,
		"1234567893" : true}
	 
	];

for(var key in botwts[0])
    console.log("==> Value from DL is : " + key);

	var botwts = [
	    {"1234567890" : true},
		{"1234567891" : true},
		{"1234567892" : true},
		{"1234567893" : true}
	 
	];

for(var i=0;i<botwts.length;i++)
   for(key in  botwts[i])
        console.log("==> Value from DL is : " + key);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
894359Author Commented:
Thank you~
1
Julian HansenCommented:
For the first example you can use Object.keys()
var keys = Object.keys(botwts[0]);
console.log(keys);

Open in new window

For the second you can use map()
var result = botwts.map(function(x) {
	return Object.keys(x)[0];
});	
console.log(result);

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.