Read, replace and write json files
npm install grunt-json-replace
> Read, replace and write json files
~0.4.0If 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-json-replace --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-json-replace');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
"json-replace": {
"options": {
"space" : "\t",
"replace" : {
"node" : {
"sub" : "value"
}
}
},
"your_target": {
"files" : [{
"src" : "in.json",
"dest" : "out.json"
}]
},
},
})
`> Note that since this is a multi-task you have to have at least one target defined for
json-replace (otherwise the task won't run)$3
#### options.replace
Type:
Object
Default value: undefinedAn object with replacement tokens. Structure should match that of the input file.
#### options.space
Type:
String
Default value: '\t'`A string value that is used to format the output JSON