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

128
Views
Parse JSON Results into Multiple HTML columns Using JQuery

I am working with an API and would like to extract API Results into an HTML table columns with X number of rows. This an issue with JQuery looping, do not know how to do it. Thanks in Advance!

/////JSON SAMPLE/////
{
  "123SC": [{
      "name": "First",
      "Custnumber": "123SC"
    },
    {
      "name": "Fourth",
      "Custnumber": "123SC"
    }
  ],
  "67BC": [{
    "name": "Second",
    "Custnumber": "67BC"
  }],
  "99ABC": [{
    "name": "Third",
    "Custnumber": "99ABC"
  }]
}
///////// END JSON //////

<table style="width:100%" border="2">
  <tr>
    <td>First</td>
    <td>Forth</td>
    <td>Second</td>
    <td>Third</td>
  </tr>
  <tr>
    <td>123SC</td>
    <td>123SC</td>
    <td>67BC</td>
    <td>99ABC</td>
  </tr>
</table>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this:

    let json = {
        "123SC": [{
            "name": "First",
            "Custnumber": "123SC"
        },
        {
            "name": "Fourth",
            "Custnumber": "123SC"
        }
        ],
        "67BC": [{
            "name": "Second",
            "Custnumber": "67BC"
        }],
        "99ABC": [{
            "name": "Third",
            "Custnumber": "99ABC"
        }]
    };

    let arrays = [];
    for (const i in json) arrays = [...arrays, ...json[i]];



    let names = '<tr>';
    let Custnumber = '<tr>';
    for (let i = 0; i < arrays.length; i++) {
        names += `<td>${arrays[i].name}</td>`;
        Custnumber += `<td>${arrays[i].Custnumber}</td>`;
    }
    names += '</tr>';
    Custnumber += '</tr>';
    let html = `<table style="width:100%" border="2">${names + Custnumber}</table>`;
    document.write(html);

about 4 years ago · Juan Pablo Isaza Report
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!