Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

291
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda