Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!