Es6 array problem

        "showModule": [{
            "action_id": "21",
            "action_name": "",
            "action_type": "1",
            "order": "1",
            "pid": "0"
        }, {
            "action_id": "20",
            "action_name": "",
            "action_type": "1",
            "order": "2",
            "pid": "0",
            "son": [{
                "action_id": "22",
                "action_name": "",
                "action_type": "2",
                "order": "1",
                "pid": "20",
                "son": [{
                    "action_id": "23",
                    "action_name": "",
                    "action_type": "3",
                    "order": "1",
                    "pid": "22"
                }, {
                    "action_id": "24",
                    "action_name": "",
                    "action_type": "3",
                    "order": "2",
                    "pid": "22"
                }, {
                    "action_id": "25",
                    "action_name": "",
                    "action_type": "3",
                    "order": "4",
                    "pid": "22"
                }, {
                    "action_id": "31",
                    "action_name": "",
                    "action_type": "3",
                    "order": "4",
                    "pid": "22"
                }]
            }, {
                "action_id": "26",
                "action_name": "",
                "action_type": "2",
                "order": "2",
                "pid": "20",
                "son": [{
                    "action_id": "27",
                    "action_name": "",
                    "action_type": "3",
                    "order": "1",
                    "pid": "26"
                }, {
                    "action_id": "28",
                    "action_name": "",
                    "action_type": "3",
                    "order": "2",
                    "pid": "26"
                }, {
                    "action_id": "29",
                    "action_name": "",
                    "action_type": "3",
                    "order": "3",
                    "pid": "26"
                }, {
                    "action_id": "30",
                    "action_name": "",
                    "action_type": "3",
                    "order": "4",
                    "pid": "26"
                }]
            }],

the data structure is like this

I want to deal with the data structure
. How should I write it like this?

showModule:{
  label: action_name,
  value: action_id,
    son:[
    {
    label: action_name,
      value: action_id,
      son:{
      label: action_name,
      value: action_id,
      }
    },
    {
    label: action_name,
      value: action_id
      }
    ]
}

if you write it like this, you can circulate the first level. If you use map on item.son, you will report an error

.
  const mapData = data.showModule.map(item => ({
      label: item.action_name,
      value: item.action_id,
      subModule: item.son
      }))
Dec.17,2021

go straight to the code:


labelvalueUI;action_idaction_namevaluelabel<br>:

data.showModule = JSON.stringify(data.showModule).relace(/action_id/g, 'value').replace(/action_name/g, 'label');
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb295a-4f8ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb295a-4f8ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?