Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda