<!DOCTYPE>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>JSON get all keys and names in Array</title>
<script>
function s(v)
{
document.getElementById("disp").innerHTML += "<br>"+v;
}
function fa(ja) // array
{
for (i=0 ; i < ja.length ; i++) fl(ja[i]);
}
function fl(jf) // JSON object
{
for (var key in jf) {
if ( jf[key] == '[object Object]') fl(jf[key]);
else if (Array.isArray(jf[key])) fa(jf[key]);
else if (key =="wbscode") s("- - - - - - -<br>"+key+" : "+jf[key]);
else s(key+" : "+jf[key]);
}
}
</script>
</head>
<body>
<div id="disp"></div>
<script>
var j1 = '{"org":"GKgroup","project":"Master Plan ","treetask":[{"wbscode":"0","content":"Master Plan ","has_child":"yes","show_child":"yes","data":{"extra":"Extra Data","predecessor":"1;2;3","created_by":"Gideon Koch","created_date":"27/08/2017"}},'+
'{"wbscode":"1","content":"Gideon Koch.com","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"1.1","content":"PM","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"1.2","content":"SE","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"2","content":"GK10","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"2.1","content":"en (Redirect to GideonKoch.com)","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"2.2","content":"home (about Hebrew)","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"3","content":"GK Blazer","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"3.1","content":"The human Factor","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"3.2","content":"FADAC","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"4","content":"PM Blazer","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"4.1","content":"integrated wbs-inpro-gantt","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"5","content":"Gantt Blazer","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"5.1","content":"tab - gantt - manage","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"6","content":"WBS Blazer","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"6.1","content":"Desired - NBS - MBS - FBS - PBS - WBS - RAM","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"7","content":"WBS Planner","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"7.1","content":"TAB - View - Manage","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},{"wbscode":"8","content":"PMsuit","has_child":"yes","child_show":"hide","data":{"extra":"","predecessor":""}},'+
'{"wbscode":"8.1","content":"Production site?","has_child":"yes","child_show":"hide","predosessors":"2;3;4","data":{"extra":"","predecessor":""}}],"mybucket":[{"content":""}]}';
d1 = JSON.parse(j1);
fa(d1["treetask"]);
fl(d1);
/*
s(d1["org"]);
s(Array.isArray(d1["treetask"]));
s(d1["treetask"][0]["content"]);
for (i=0 ; i < d1["treetask"].length ; i++) {
// s(d1["treetask"][i]["wbscode"]);
for (var key in d1["treetask"][i])
if ( d1["treetask"][i][key] != '[object Object]')
s(key+" : "+d1["treetask"][i][key]);
s("");
}
*/
</script>
</body>
</html>