[enter image description here][1] i have json file that i'm gonna use as DB. dictionaries are different some of them has more child dictioanries. i have to print all items with price and amount. aloso i have to print in table their total price like in immage bellow. [enter image description here][2] [1]: https://i.stack.imgur.com/pmgqC.png [2]: https://i.stack.imgur.com/OseLv.png
function checkNextObject(check) {
var c = Object.keys(check);
if (typeof check[c[0]] === "object") {
var cc= Object.keys(c)
return typeof c[cc[0]] === "object" ;
} else return false;
}
function recursiveTable(dictObject,parent= {"name":"","total":0},child={},table={"items":[],"coutner":0}) {
var keys = Object.keys(dictObject);
keys.forEach(key => {
if (checkNextObject(dictObject)) {
return recursiveTable(dictObject[key],parent,child,table);
} else {
var row = {key:dictObject[key],"parents":parent}
table["items"].push(row)
}
}) ;
return table;
}