The React project uses ant Table components to generate columns dynamically

1. Description: the company does a background project, which needs to render the list. I use the Table component of ant, but it is required to generate columns, dynamically according to the data. is there any way to dynamically generate the corresponding columns of similar data?
2. Data structure: const schemasMessage = [

{
    "code": "011234567890",
    "generalInfo": {
        "name": "xx",
        "shortName": "xx",
        "taxPayerType": "xx",
        "taxPayerTypeId": "1",
        "registeredCapital": 500,
        "characterOfEconomy": "xxx",
        "characterOfEconomyId": "21"
    },
    "transaction": {
        "bankName": "xx",
        "bankAccount": "1234567890",
        "bankLocation": {
            "province": "xx",
            "city": xx",
        }
    },
    "location": {
        "province": "",
        "city": "",
        "district": "",
        "street": "xx",
        "address": "xx",
        "postCode": "01000000"
    },
    "contacts": [
        {
            "name": "xx",
            "position": "xx"
        },
        {
            "name": "xx",
            "position": "xx"
        }
    ],
    "marketing": {}
}]
const columns = [
{title:"Code",dataIndex: "code",key:"code",fixed: "left"},
{title: "GeneralInfo",
    children:[
        {title:"Name",dataIndex: "name",key:"name"},
        {title:"shortName",dataIndex: "shortName",key:"shortName"},
    ]

}, {

title: "Transaction",
children: [{
    title: "bankName",
    dataIndex: "bankName",
    key: "bankName",
},
    { title: "bankAccount",
        dataIndex: "bankAccount",
        key: "bankAccount",},
    {
    title: "bankLocation",
    children: [{
        title: "province",
        dataIndex: "province",
        key: "province",
    }, {
        title: "city",
        dataIndex: "city",
        key: "city",
    }],
}],

},

{
title: "contacts",
children: [{
    title: "contacts1",
    children:[
        {title: "Name",
            dataIndex: "name",
            key: "name",},
        {title: "position",
            dataIndex: "position",
            key: "position",},
    ]
},{
    title: "contacts2",
    children:[
        {title: "Name",
            dataIndex: "name",
            key: "name",},
        {title: "position",
            dataIndex: "position",
            key: "position",},
    ]
}],

}];

how can I achieve this?

Mar.19,2021

function adds(datas){
     var arr=[]
     Object.keys(datas).map(r=>{
      if(typeof datas[r] == 'object'){
       arr.push({title:r,children:adds(datas[r])})
     }else{
      arr.push({title:r,dataIndex:r,key:r})
    }
                  
    })
     return arr
  }
              
  console.log(adds(schemasMessage[0]))
 
  "contacts": [
        {
            "name": "xx",
            "position": "xx"
        },
        {
            "name": "xx",
            "position": "xx"
        }
    ],
    
  function adds(datas){
     var arr=[]
     Object.keys(datas).map(r=>{
     if(!Array.isArray(datas[r])){
     if(typeof datas[r] == 'object'){
        arr.push({title:r,children:adds(datas[r])})
     }else{
        arr.push({title:r,dataIndex:r,key:r})
     }
    }else{
      console.log(datas[r])
      let arrs={'title':r,'children':[]}
      arrs.children =datas[r].map((rs,index)=>{
      if(typeof rs== 'object'){
        return    {title:r+index,children:adds(rs)}
      }else{
        return {title:rs,dataIndex:rs,key:rs}
      }
     })
        arr.push(arrs)
     }
     })
      return arr
      }
              
    console.log(adds(schemasMessage[0]))  
    
Menu