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

126
Vistas
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 Respuestas
Responde la pregunta

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 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