Grunt task to turn CSVs into JSON
npm install grunt-csv2json> Turn CSVs into JSON using the Grunt CLI
~0.4.5If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
``shell`
npm install grunt-csv2json --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-csv2json');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
csv2json: {
options: {
inputFilePath: 'csv',
outputFilePath: 'json'
}
}
});
`$3
#### options.inputFilePath
Type:
String
Default value: 'csv'A string value that points to the directory where your .csv file is.
#### options.outputFilePath
Type:
String
Default value: 'json'A string value that points to where your .json file will be output.
$3
grunt csv2json:sample will look for a .csv file named sample` in the specified csv directory and automatically generate a corresponding JSON file in the specified JSON directory.