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

122
Views
Coverting JSON to JavaScript Object with just values

I have some JSON where I need to convert just the values to an Object. How would I go about this?

My JSON is

[
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:30:00",
  "TheDate": "2021-12-23",
  "Hits": "39"
},
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:45:00",
  "TheDate": "2021-12-23",
  "Hits": "37"
}
]

and I am trying to format it like so (without the names)

var myObject = [["Acme Inc.", "08:30:00", "2021-12-23", "39"], ["Acme Inc.", "08:45:00", "2021-12-23", "37"]];

I need to do this with assuming that the code doesn't know the names. That way I can reuse the code on another JSON file without having to tweak the code each time.

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

0

Just .map it with Object.values:

let json = `[
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:30:00",
  "TheDate": "2021-12-23",
  "Hits": "39"
},
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:45:00",
  "TheDate": "2021-12-23",
  "Hits": "37"
}
]`;

let result = JSON.parse(json).map(e => Object.values(e));

console.log(result);

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!