feat: fixing bug in object
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "async-convert-csv-to-json",
|
"name": "async-convert-csv-to-json",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"description": "convert csv file to json",
|
"description": "convert csv file to json",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -6,8 +6,8 @@ const csvToJson = (csv) => {
|
|||||||
const result = [];
|
const result = [];
|
||||||
const headers = lines[0].split(',');
|
const headers = lines[0].split(',');
|
||||||
const contents = lines.slice(1, lines.length - 1)
|
const contents = lines.slice(1, lines.length - 1)
|
||||||
const obj = {};
|
|
||||||
for (const content of contents) {
|
for (const content of contents) {
|
||||||
|
const obj = {};
|
||||||
const currentline = content.split(',');
|
const currentline = content.split(',');
|
||||||
for (let j = 0; j < headers.length; j++) {
|
for (let j = 0; j < headers.length; j++) {
|
||||||
obj[headers[j]] = currentline[j];
|
obj[headers[j]] = currentline[j];
|
||||||
|
Reference in New Issue
Block a user