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

115
Vistas
JSON jQuery auto-fill

first of all, I really haven't learn any javascript at all, and I am stuck here.

code for auto-fill input that I got from a friend.

I want to get these link in this JSON example.

"list": [
    [
      "List of recipes",
      [
        {
          "name": "Eggs",
          "links": [
            {
              "method": "Fry",
              "link": "https://example.com/category/fry"
            },
          ]
        },
      ]
    ]

I can't elaborate with my friend's example code, can anyone help me?

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

0

  1. Your JSON isn't valid so you need to fix that first.

  2. When it's valid parse it with JSON.parse.

  3. When it's parsed you'll have a nested array data structure. You need to access the links array by navigating through the tree with the array indexes.


// Returns an array
data.list[0]

// Get the second element of that array
// (the first element is the text "List of recipes")
// which is also an array
data.list[0][1]

// Access the first element of that array
// (an object) and return the links array
data.list[0][1][0].links

const json = '{"list":[["List of recipes",[{"name":"Eggs","links":[{"method":"Fry","link":"https://example.com/category/fry"}]}]]]}';

const data = JSON.parse(json);

console.log(data.list[0][1][0].links);

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