Reputation: 809
I have this json
{
"3": {
"builderName": "All Branches",
"currentStep": {
"eta": 46.228333592710214,
"expectations": [
[
"output",
1519065,
1565397.0
]
],
I want to get keys and values from currentStep. Like eta and expectations.
$.each(obj, function (key, value) {
$.each(value.currentStep, function (key, value) {
console.log(value.eta); // this returns undefined
});
});
Upvotes: 0
Views: 46
Reputation: 7518
You already have the key and value.
$.each(json, function (key, value) {
$.each(value.currentStep, function (key, value) {
console.log(key + " : " + value);
});
});
Upvotes: 2
Reputation: 318488
This will log the keys/values of currentStep:
$.each(obj, function(key, value) {
$.each(value.currentStep, function(key, value) {
console.log(key, value);
});
});
Upvotes: 1