Convert RESX files into structured JSON files using a delimited key value.
This plugin requires Grunt >=0.4.5
If 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:
npm install grunt-resx-to-json-delimited --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-resx-to-json-delimited');
Specify a delimiter
value to generate a structured JSON object.
For example:
Given a delimiter
value of '_'
and RESX entry with the key:
'book_chapter_page'
Would produce the following object structure:
{
"book": {
"chapter": {
"page": //RESX value would be inserted here.
}
}
}
In your project's Gruntfile, add a section named resx_to_json_delimited
to the
data object passed into grunt.initConfig()
.
grunt.initConfig({
resx_to_json_delimited: {
files: {
// Source and Destination files go here.
},
options: {
// Task-specific options go here.
},
},
});
Type: String
Default value: undefined
A delimiter value used to create the nested JSON object from the RESX key.
Type: String
Default value: 'json'
A string value that will be used as the file extension for all destination files.
Type: String
or Number
Default value: undefined
A string or number object that's used to insert white space into the output JSON string for readability purposes.
In this example, the default options are used to create a JSON file from a RESX file. With no options specified, the destination result will be flat JSON files without any nested properties.
grunt.initConfig({
resx_to_json_delimited: {
options: {},
files: {
'dest/default' : 'src/**'
},
},
});
In this example, the specified delimiter
option will be used to split
the RESX key into a nested JSON object.
grunt.initConfig({
resx_to_json_delimited: {
options: {
delimiter: '_'
},
files: {
'dest/default' : 'src/**'
},
},
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- 2016-10-24 v0.1.3 Update devDependencies. Added
whitespace
option. Fixed JSHINT errors.