I have the nested json as below. I need to iterate the json and have to get each value.
{
"processDefId": "xyz",
"name": "name",
"sla": "10",
"hasChild": true,
"child": [
{
"activityDefId": "siteSurveyDef",
"activityName": "Site Survey",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true,
"child": [
{
"activityDefId": "Begin",
"activityName": "Begin",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true
},
{
"activityDefId": "Site Survey2",
"activityName": "Site Survey2",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true
}
]
},
{
"activityDefId": "siteSurvey",
"activityName": "Procurement",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true,
"child": [
{
"activityDefId": "Begin",
"activityName": "Begin"
},
{
"activityDefId": "Site Survey",
"activityName": "Site Survey3",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true
}
]
},
{
"activityDefId": "siteSurvey",
"activityName": "Provisioning",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true,
"child": [
{
"activityDefId": "Begin",
"activityName": "Begin"
},
{
"activityDefId": "Site Survey",
"activityName": "Site Survey4",
"isMandatory": "true",
"isOptional": "false",
"sla": "10",
"sequence": "1",
"hasChild": true
}
]
}
]
}
I tried to loop like this:
$.each(hiddenJson, function() {
$.each(this, function(name, value) {
//var sla = me.sla;//use `this` from outer scope
//alert(sla);
console.log(name + '=' + value);
});
});
I am not getting value properly.Can anyone please suggest?