feat: fixing bug in object

This commit is contained in:
Carlos 2024-03-24 20:58:09 -04:00
parent fd6b40ca19
commit e24cb16e8e
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "async-convert-csv-to-json",
"version": "1.4.1",
"version": "1.4.2",
"description": "convert csv file to json",
"main": "index.js",
"scripts": {

View File

@ -6,8 +6,8 @@ const csvToJson = (csv) => {
const result = [];
const headers = lines[0].split(',');
const contents = lines.slice(1, lines.length - 1)
const obj = {};
for (const content of contents) {
const obj = {};
const currentline = content.split(',');
for (let j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];