Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
JSON jQuery autocompletar

en primer lugar, realmente no he aprendido nada de javascript, y estoy atrapado aquí.

código para la entrada de autocompletar que recibí de un amigo.

Quiero obtener estos link en este ejemplo JSON.

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

No puedo elaborar con el código de ejemplo de mi amigo, ¿alguien puede ayudarme?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Su JSON no es válido, por lo que debe corregirlo primero.

  2. Cuando sea válido, analícelo con JSON.parse .

  3. Cuando se analice, tendrá una estructura de datos de matriz anidada. Debe acceder a la matriz de enlaces navegando a través del árbol con los índices de la matriz.


 // 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!