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

294
Views
Exporte datos Json a texto sin formato usando Pure Javascript

Tengo la función Javascript que exporta json a un archivo txt

 function download() { const originalData = [ { name: 'Support', message: 'Hey! Welcome to support', }, { name: 'Me', message: 'Hello there!', }, { name: 'Support', message: 'What can I do for you?', }, ]; var items = originalData; const replacer = (key, value) => (value === null ? '' : value); // specify how you want to handle null values here const header = Object.keys(items[0]); let csv = items.map((row) => header .map((fieldName) => JSON.stringify(row[fieldName], replacer)) .join(',') ); csv.unshift(header.join(',')); csv = csv.join('\r\n'); //Download the file as CSV/TXT just change the extension var downloadLink = document.createElement('a'); var blob = new Blob(['\ufeff', csv]); var url = URL.createObjectURL(blob); downloadLink.href = url; downloadLink.download = 'DataDump.txt'; //Name the file here document.body.appendChild(downloadLink); downloadLink.click(); document.body.removeChild(downloadLink); }

el resultado es

 name,message "Support","Hey! Welcome to support" "Me","Hello there!" "Support","What can I do for you?"

El valor esperado que quiero es así, se incluye '*' en cada última cadena en la fila> 1

name,message "Support","Hey! Welcome to support"* "Me","Hello there!"* "Support","What can I do for you?"*

Cómo agregar '*' en línea> 1 o fila> 1

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

0

Probablemente, lo más fácil sería agregar el * al crear las líneas de su CSV.

 let csv = items.map((row) => header .map((fieldName) => JSON.stringify(row[fieldName], replacer)) .join(',') + "*" );
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!