Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda