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

236
Visualizações
Why is my JSON object showing [Array] instead of the data in javascript after reformatting?

Currently I am trying to create a JSON object in java script which has an additional array containing all of the data that I currently posses:

src is a JSON object which before any code is run is equal to:

[
  {
    _id: new ObjectId("629ac43586b27bfd70337d06"),
    Title: 'Test Poll',
    Option: [ 'Test Option 1', 'Test Option 2', 'Test Option 3' ]
  },
  {
    _id: new ObjectId("629afc9286b27bfd70337d09"),
    Title: 'Test Poll 2',
    Option: [ 'Test Option 1' ]
  }
]

I need to reformat this object so that it is contained within a separate array which I am currently attempting to do with this line:

  var context = { poll:src };

This results in a reformatting of the JSON object which I do not understand, after running this code context contains:

  poll: [
    {
      _id: new ObjectId("629ac43586b27bfd70337d06"),
      Title: 'Test Poll',
      Option: [Array]
    },
    {
      _id: new ObjectId("629afc9286b27bfd70337d09"),
      Title: 'Test Poll 2',
      Option: [Array]
    }
  ]

It gets rid of the Option arrays and replaces them with [Array]. I need to keep these arrays and I am not sure what to change to fix this as I have tried looking elsewhere for answers. Does anyone have an idea of what is going on here?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ok they are arrays I am just too new to realize that it would not print fully. I was attempting to use handlebars on these Option arrays to print the list and I was forgetting to use the implicit this for the variable name instead of just 'Option'.

Problem solved.

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