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

116
Views
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 answers
Answer question

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 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!