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

119
Views
object conversion between objects javascript

how to change object from

const ob = {
  "61ac2727bc40d842e43c8726": {
    nama: {
      value: "dianaasdasd",
    },
    username: {
      value: "diana",
    },
    email: {
      value: "diana@gmail.com",
      error: false,
    },
    userlevel: {
      value: "karyawan",
    },
    password: {
      value: "************************************************************",
    },
    jenis_kelamin: {
      value: "Perempuan",
    },
    alamat: {
      value: "sasddad",
    },
  },
};  

remove "61ac2727bc40d842e43c8726", value and return object as follows how to convert to

this image

https://i.stack.imgur.com/6Qi1C.png

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

0

You can do it like this

const ob = {
  "61ac2727bc40d842e43c8726": {
    nama: {
      value: "dianaasdasd",
    },
    username: {
      value: "diana",
    },
    email: {
      value: "diana@gmail.com",
      error: false,
    },
    userlevel: {
      value: "karyawan",
    },
    password: {
      value: "************************************************************",
    },
    jenis_kelamin: {
      value: "Perempuan",
    },
    alamat: {
      value: "sasddad",
    },
  },
};  


// remove 61ac2727bc40d842e43c8726
const obWithoutKey = Object.values(ob)[0];

// extract key values
const obExpected = Object.entries(obWithoutKey)
.reduce((acc, [key, val])=>{ 
  console.log(key, val)
 acc[key]=val.value 
 return acc;
  
}, {})

console.log(obExpected)
about 4 years ago · Juan Pablo Isaza Report

0

You can generate your object like this:

const { '61ac2727bc40d842e43c8726': {...obj} } = ob;
let newObj = {};
for(let key in obj){
 newObj[key] = obj[key].value
}
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!