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

238
Vistas
How do you parse a json object that has this format instead of an array

How do you properly parse a json object that has the following structure;

{
  "cutoffTimes" : {
    "85c46c49-99b6-47a1-9726-960c8fe6c337" : {
      "id" : "85c46c49-99b6-47a1-9726-960c8fe6c337",
      "customerId" : "fc0097ec-9c41-467f-9b81-50d9a07c65e8",
      "time" : "17:00:00",
      "deadlineCutoffType" : "TRANSMISSION"
    },
    "1784efdd-750f-4bae-b65f-179a4e8c28f3" : {
      "id" : "1784efdd-750f-4bae-b65f-179a4e8c28f3",
      "customerId" : "fc0097ec-9c41-467f-9b81-50d9a07c65e8",
      "time" : "18:00:00",
      "deadlineCutoffType" : "TRANSMISSION"
    },
    "86a2d573-e4f4-451a-930e-99922f1f229d" : {
      "id" : "86a2d573-e4f4-451a-930e-99922f1f229d",
      "customerId" : "fc0097ec-9c41-467f-9b81-50d9a07c65e8",
      "time" : "21:30:00",
      "deadlineCutoffType" : "TRANSMISSION"
    }
}

I would typically do

let _times = JSON.parse({jsondoc});
console.log(`There are ${_times.cutoffTimes.length} times available`);

However, in this document, the cutoffTimes is not an array.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could use Object.keys to check the length. It converts your object to array like ['85c46c49-99b6-47a1-9726-960c8fe6c337', '1784efdd-750f-4bae-b65f-179a4e8c28f3', ...]

console.log(`There are ${Object.keys(_times.cutoffTimes).length} times available`);
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