Q:

How to Destructure a huge JSON object dynamically?

class Options extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      //previously called validOptions //Whether JSON_output has been uploaded to Azure
      optionAvailbility: false,
      // dataEngineResult: null
      dataEngineResult: {
        attribute_description: {
          age: {
            name: "age",
            data_type: "Integer",
            category: {
            ...
          },
          education:{...},
          income:{...},
          ....
       }
    }
   }
  }
}

Basically I have this huge json object that is a result obtained from azure, which I update to my state in my Option.js component. 
Within this component, I want to retrieve all of the attributes via destructing. 
Why is this method wrong:
const ageAttr, educationAttr..., incomeAttr = this.state.dataEngineResult.attribute_description

Thank you in advance!

A:

Since attribue_description is an object. You should use object destructuring and use the name of the property you want to get.
const { age, education, income } = this.state.dataEngineResult.attribute_description

If you want to change the name you can do like so
const { age: ageAttr, education: educationAttr, income: incomeAttr } = this.state.dataEngineResult.attribute_description

