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

125
Visualizações
How to separate different objects appearing on the same line?

So I created an array of objects that contain some data like name, id, etc.... I used the res.json() method to transform the array of objects into json data so that my browser would be able to use it. The problem is that I typed the array of object data like this:

[
  {

    id: 1,
    name: 'albany sofa', 
    image:   'https://dl.airtable.com/.attachments/6ac7f7b55d505
    price: 39.95,
    desc: `I'm baby direct trade farm-to-table hell of, YOLO readymade raw denim venmo whatever organic gluten-free kitsch schlitz irony af flexitarian.`,
  }, 

  {

    id: 2,
    name: 'entertainment center',
    image:'https://dl.airtable.com/.attachments/
    price: 29.98,
    desc: `I'm baby direct trade farm-to-table hell of, YOLO readymade raw denim venmo whatever organic gluten-free kitsch schlitz irony af flexitarian.`,
  },
]

Whenever I launch my server, the data comes out like this:

`[{"id":1,"name":"albanysofa","image":"https://dl.airtable.com/.attachments/6ac7f7b55d505057317534722e5a9f03/9183491e/product-3.jpg","price":39.95,"desc":"I'm baby direct trade farm-to-table hell of, YOLO readymade raw denim venmo whatever organic gluten-free kitsch schlitz irony af flexitarian."},{"id":2,"name":"entertainmentcenter","image":"https://dl.airtable.com/.attachments/da5e17fd71f50578d525dd5f596e407e/d5e88ac8/product-2.jpg","price":29.98,"desc":"I'm baby direct trade farm-to-table hell of, YOLO readymade raw denim venmo whatever organic gluten-free kitsch schlitz irony af flexitarian."}`

Meaning that it appears on one line. Meanwhile when I typed it out, I organized it. How do I fix it? Is this not as big an issue as I am seeing it? Also, when I checked for the content-type in the browser, it was missing.

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

0

Addidional spaces and new lines are ignored inside JSON. So the JSON data you have posted is perfectly valid and will be parsed normal by any fuction that requires a JSON parameter. Many API testing tools support JSON beautify ex. in Postman by default, JSON is represented "Pretty".

enter image description here

If for readability or other reasons you'd want to view your JSON like that, you can use 3rd party JSON beautifier tools.

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