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

124
Views
¿Cómo separar diferentes objetos que aparecen en la misma línea?

Así que creé una matriz de objetos que contienen algunos datos como nombre, identificación, etc. Usé el método res.json() para transformar la matriz de objetos en datos json para que mi navegador pudiera usarlo. El problema es que escribí la matriz de datos de objetos de esta manera:

 [ { 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.`, }, ]

Cada vez que lanzo mi servidor, los datos salen así:

 `[{"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."}`

Lo que significa que aparece en una línea. Mientras tanto, cuando lo escribí, lo organicé. ¿Cómo lo soluciono? ¿No es un problema tan grande como lo estoy viendo? Además, cuando revisé el tipo de contenido en el navegador, faltaba.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Los espacios adicionales y las nuevas líneas se ignoran dentro de JSON. Por lo tanto, los datos JSON que ha publicado son perfectamente válidos y serán analizados normalmente por cualquier función que requiera un parámetro JSON. Muchas herramientas de prueba de API admiten JSON beautify ex. en Postman por defecto, JSON se representa como "Pretty".

ingrese la descripción de la imagen aquí

Si por legibilidad u otras razones desea ver su JSON así, puede usar herramientas de embellecimiento de JSON de terceros.

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!