Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
How can I rename the "key" name of an object which is inside array in Node Js?

I am having trouble renaming the key of an object which is inside the array and not only this the name of the is empty as shown below

    {
   "success": true,
    "data": [
        {
            "": "abc123abc"
        }
            ]
    }

If I want to give the name to the key, how would I be able to do that in Node Js?

Like If want to give a key name like this shown below

    {
    "success": true,
    "data": [
        {
            "application_num": "abc123abc"
        }
    ]
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

There are two components to solving this issue - referencing the item with an empty name, and renaming it.

To reference any property, even with special characters or in this case an empty string, you can specify the property name as a string in square brackets like so:

data["my property with spaces"]
data[""]

Now that we can reference the empty property name, we now need to rename it. This can be achieved by deleting the original property and creating a new one with the same value. You can delete the property with the delete keyword, as follows

delete data[""]

Here is the complete final answer, which stores the value in a temporary variable, deletes the property you don't want, and assigns the stored value to a new different property name:

const data = {
   "success": true,
    "data": [
        {
            "": "abc123abc"
        }
            ]
    }
const dataObjectToModify = data.data[0]
const originalPropertyValue = dataObjectToModify[""]
delete dataObjectToModify[""]
dataObjectToModify["application_num"] = originalPropertyValue
about 4 years ago · Juan Pablo Isaza Report

0

a = {
   "success": true,
    "data": [
        {
            "": "abc123abc"
        }
            ]
    }

//{
//    "success": true,
//    "data": [
//        {
//            "application_num": "abc123abc"
//        }
//    ]
//}
//--------------------------------

a["data"][0] = {"application_num" : "abc123abc"}

//{
//    "success": true,
//    "data": [
//        {
//            "application_num": "abc123abc"
//        }
//    ]
//}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!