

In case your CSV file has defined another field delimiter you have to call the function fieldDelimiter(myDelimiter) and pass it as parameter the field delimiter.Į.g.

As default the field delimiter is the semicolon ( ), this means that during the parsing when a semicolon ( ) is matched a new JSON entry is created.

To generate the JSON Object with sub array from the above CSV example: csvToJson.parseSubArray('*',',').getJsonFromCsv('myInputFile.csv') Ī field delimiter is needed to split the parsed values. With the values diego,marek,dries you have to call the function parseSubArray(delimiter, separator). } Generate Object with sub array the above CSV example, to generate a JSON Object with properties that contains sub Array, like the property sons Let json = csvToJson.getJsonFromCsv("myInputFile.csv") Let fileOutputName = 'myOutputFile.json' ĬsvToJson.generateJsonFileFromCsv(fileInputName,fileOutputName) Generate Array of Object in JSON format let csvToJson = require('convert-csv-to-json') Install package on your machine $ npm install -g convert-csv-to-json Usage Generate JSON file let csvToJson = require('convert-csv-to-json') Install package in your package.json $ npm install convert-csv-to-json -save Generate Array of Object in JSON formatĬonverts csv files to JSON files with Node.js.Install npm convert-csv-to-json package.This project is not dependent on others packages or libraries.
