grunt-json2js
Compiles JSON files into JavaScript
Getting Started
Install grunt-json2js via NPM
npm install grunt-json2js
Then add this line to Gruntfile:
grunt.loadNpmTasks('grunt-json');
Options
namespace
Type: String
Default: 'json'
The namespace in which the json data will be assigned.
noVar
Type: Boolean
Default: true
If you are defining a namespace which contains .
then set this to false
.
Example Grunt configuration
json2js: {
main: {
options: {
namespace: 'i18n'
},
src: ['path/to/source/**/*.json'],
dest: 'path/to/compiled/json.js'
}
}
Acknowledgements
This is a modified version of grunt-json which was authored by Wilson Page. [grunt-json]: https://github.com/wilsonpage/grunt-json