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

114
Vistas
How to access dynamic key values in nested objects

This is my JSON file:

{
 "Key": "some-key",
        "some-key": {
        "comLength": 1
        },
}

How do I access the comLength value?

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

0

I would do this

  1. parse to custom object
  2. do a For-loop by the required property
  3. break the loop as soon I found the match
about 4 years ago · Juan Pablo Isaza Denunciar

0

Considering your object variable is named someObject, you can access it like:

var comLength = someObject["some-key"].comLength

Example:

var someObject = {
     "Key": "some-key",
     "some-key": {
        "comLength": 1
     },
}

var comLength = someObject["some-key"].comLength;

console.log(comLength);

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can reference it via the dot notation (.) and the square notation ([]) (the [] notation is mandatory in case of the property key of some-key because of the -)

const obj = {
    "Key": "some-key",
    "some-key": {
            "comLength": 1
        }
};


console.log(obj["some-key"].comLength);
console.log(obj["some-key"]["comLength"]);

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