Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

357
Views
dictionary to table converter

[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;

}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!