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

109
Vistas
How to access the below object parameters in Javascript
output = "{\"response\":200,\"message\":\"Id: 123 updated successfully\"}{\"response\":403,\"message\":\"Receipt with Id: 124 not updated\"}"

How to access the response on the above output? Unable to convert to json due to invalid format

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

0

The output you have is almost valid, you could put the two objects into an array and walk through them to check for the key value 'response' and for example print the values like so:

output = [{"response":200,"message":"Id: 123 updated successfully"},
          {"response":403,"message":"Receipt with Id: 124 not updated"}];
for(let i=0; i<output.length; i++){
  if(output[i].hasOwnProperty('response')){
      console.log(output[i]['response']);
   }
 }

Output:

200
403

Please note the '[]' brackets put around the response objects returned to make the variable 'output' iterable.

about 4 years ago · Juan Pablo Isaza Denunciar

0

try the following:

output = `{"response":200,"message":"Id: 123 updated successfully"}{"response":403,"message":"Receipt with Id: 124 not updated"}`
output = output.replaceAll("}", "},");
output = output.substring(0, output.length - 1);
output = "[" + output  + "]"

console.log(output)
console.log(JSON.parse(output) )

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