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

97
Views
convert deep nested array of object into plain tab separated string

i have three-level or more nested JSON I need to convert it into nice looking string

for example

let a = {
    "spec":[
        {'key': 'General', 'values': [
            {'key': 'Model Number', 'value': 'REDMI'},
            {'key': 'Year of Manufacture', 'value': '2022'},
            {'key': 'SIM Type', 'value': 'Dual Sim'}
        ]},
        {'key': 'OS & Processor Features', 'values': [
            {'key': 'Operating System', 'value': 'Andriod'
            },
            {'key': 'Processor Type', 'value': 'MediaTek'
            },
            {'key': 'Processor Core', 'value': 'Octa Core'
            },
            {'key': 'PCS', 'value': '2 GHz'
            },
        ]
    }
        
    ]
}

into something like this

General
  Model Number : REDMI
  Year of Manufacture : 2022
  SIM Type : Dual Sim
OS & Processor Features
  Operating System : Andriod
  Processor Type : MediaTek
  Processor Core : Octa Core
  PCS', 'value': '2 GHz\

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

0

Here you go:

let a = {...}
let formattedText = ""
for (let spec of a["spec"]) {
  formattedText += spec["key"] + "\n"
  for (let value of spec["values"]) {
    formattedText += `\t${value["key"]} : ${value["value"]}\n`
  }
}

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