remove the inner reference of the object

You could spread glazingSimpleMaterial and remove that prop

const originalValues = {
  "glazingSimpleMaterial": {
    "name": "Test",
    "solarName": "Test1"
  },
  "other": "other",
  "another": "another"
}

const modify = (originalValues) => {
  const res = { ...originalValues, ...originalValues["glazingSimpleMaterial"] }
  delete res["glazingSimpleMaterial"]
  return res
}

const res = modify(originalValues);

console.log(res)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top