CraZyDroiD
CraZyDroiD

Reputation: 7127

Access value in a object using key value

i have a object like the following

{"7036":{"7073":"","7075":"","7077":"","7079":"2","7352":"3"}

How do i read the value of 7352 if that's the only information i have?

For ex: i want to get the value of 3 and in my code i can get the value of 7352

Upvotes: 0

Views: 31

Answers (1)

Mohsen
Mohsen

Reputation: 1422

var json = '{"7036":{"7073":"","7075":"","7077":"","7079":"2","7352":"3"}}';
var obj = JSON.parse(json);
for(var k in obj) {
  var innerObj = obj[k];
  for(var item in innerObj) {
    console.log(item);
    console.log(innerObj[item])
  }
}

Upvotes: 1

Related Questions