mholt / PapaParse

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
http://PapaParse.com
MIT License
12.44k stars 1.14k forks source link

Bug with unparsing empty objects #802

Closed casperbrike closed 4 years ago

casperbrike commented 4 years ago

Prerequisites

PapaParse: 5.2.0 Environment: Node 10.14.1

Description

Empty objects are converted into [object Object] string instead of empty string when unparsing data.

Steps to reproduce

const Papa = require('papaparse')

console.log(
  Papa.unparse(
    [[null, undefined, 1, new String("lorem"), {}]]
  )
)

Expected

,,1,lorem,

Actual

,,1,lorem,[object Object]
pokoli commented 4 years ago

For me if you pass an object it is correct to add them it with it's string representation on the file. So this is not a bug.

PapaParse is focused on CSV parsing/unparsing and it does not try to convert the data that it receives, this is the user responsability. So for me you should ensure that the right values are passed to the unparse method.