Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
How to drill into a JSON object to get the arrays when what should work doesn't

So, I have a similar situation as with this question which "SHOULD" work but doesn't

How can I access and process nested objects, arrays or JSON?

My JSON is basically this... reduced for brevity.

NOTE:

"{"message": [{"id":"1","element1":"Something","element1":"Something"},{"id":"2","element1":"Something","element1":"Something"}],"status": "success"}"

What happens is that if I select response coming from the API, I get the entire JSON.

If I type: response.message, I get UNDEFINED. That makes absolutely no sense.

enter image description here

This is what it looks like in sessionStorage:

enter image description here

I just want to do what I've always done: response.message or response.whatever to just give me what's "INSIDE" message and for some reason, no matter what I do, it's not working.

Here's the part of the code where I get the response with message

globalService.commonService('getData', reqPkg).then((response) => {
   $scope.theReport.data = JSON.parse(response);
});

if I do this I get undefined

$scope.theReport.data = JSON.parse(response.message);

I've tried JSON.stringify too, same result.

This is from a previous question which works fine and is in deed just the Objects from the Array of Objects.

const arrResult = Object.keys(objCount).map(k => ({'name': k, 'displayName': k, 'count': objCount[k] }));
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

$scope.theReport.data = JSON.parse(response).message; to get all entries from message into $scope.theReport.data. Your response is a string, so parse the response and just grab the message key from that.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda