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

129
Vistas
Changing value after parsing from API

I'm parsing the following from:

    json.listMap.forEach((listItem: { State: string; Country: string})```

Response.data looks like this:
```{
  success: true,
  listMap: [
    {
      State : 'Northrine Westfalia',
      Country: 'Germany'
    },
    {
      {
      State : 'Bavaria',
      Country: 'Germany'
    }
    }
  ]
}

How can I convert the value in country currently being 'Germany' to 'Deutschland' after parsing it from the API using Java Script?

-> Let me be more open here. I don't really know that method I could use to do this. Maybe someone could point me at a documentation, of course I don't expect anyone to just hand me the code.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Use Array.map after parsing JSON into an JavaScript array:

const list = response.listMap.map(entry => {
  return {
    State : entry.State,
    Country: entry.Country.replaceAll('Germany', 'Deutschland')
  }
})

Of course, if you need JSON structure, just convert final array into JSON string with the following:

const newJSONList = JSON.stringify(list);
about 4 years ago · Juan Pablo Isaza Denunciar

0

try this :

listMap = listMap.map(listMapItem => {
if ('Germany'===listMapItem.Country) {
    listMapItem.Country = 'Deutschland';
    return listMapItem;
} else {
    return listMapItem;
}
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

assuming below is your response object.

var responsObj={  success: true,
listMap: [
    {
      State : 'Northrine Westfalia',
      Country: 'Germany'
    },
      {
      State : 'Bavaria',
      Country: 'Germany'
    }
  ]
};
responsObj.listMap=responsObj.listMap.map(x=>{
  if(x.Country=="Germany"){
    x.Country="Deutschland";
  }
  return x;
});
console.log(responsObj.listMap);

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