I'm trying to help a JSON structure format from an existing project, and the goal is to rename some subkeys not the value. The JSON format like this
{
"table-name": "Kiwi",
"created-on": "November 20, 2021",
"token": "lsUVozOB2TxhvMv",
"icons": "default",
"links": "default",
"extra": "default",
"mode": "Private",
"collaborators": [],
"columns": {
"Name": {
"type": "text",
"extra": ""
},
"Info": {
"type": "longtext",
"extra": ""
},
"Status": {
"type": "droplist",
"extra": {
"fr": "Pending",
"sc": "On-going",
"th": "Completed",
"fo": "Cancelled"
}
}
},
"data": [{
"Name": "Team Reports",
"Info": "Submitting marketing materials reports",
"Status": "Completed"
},
{
"Name": "Fabia HR",
"Info": "Brian asking for a report",
"Status": "Pending"
},
{
"Name": "Fabia",
"Info": "Meeting with CEO @cafe 9:00",
"Status": "Cancelled"
}
]
}
And we're looking into the columns
to rename the Name
into Task
and still keep the other. After using array push and slice the keys, I'm getting 0
as the keys and "Task as subkeys like
"0":{
"Task":{
"type":"text",
"extra":""
},
The code looks like this. Please do share your solutions in your spare time, thank you in advance, really appreciate any attention. Total noob here