1.0.0 • Published 7 years ago

@asthajadia12/jsonconverter v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

jsonconverter

A Nodejs module that converts csv to json.

Installation:

$ npm i jsonconverter

API

.csvToJson(csvData, option, callback( err, data ){ }) option parameter:

  • fromFile: set true if you are passing data through file.
  • toFile: : set true if you want output in the form of file.

Examples

Conversion of raw csv to raw json as output.

var jsonc = require('@asthajadia12/jsonconverter');

jsonc.csvToJson(csvData, {},
  function (err, data) {
      return data; // returns raw data
})

Conversion of csv file data to raw json as output.

jsonc.csvToJson(csvFilePath, { fromFile: true },
  function (err, data) {
      return data; // returns raw data
})

Conversion of csv file data to json file as output.

jsonc.csvToJson(csvFilePath, { fromFile: true, toFile: true },
  function (err, data) {
      return data; // returns output as output.json in currenct directory
})

License

MIT