grunt-json-extend

0.0.5 • Public • Published

grunt-json-extend

grunt plugin for generate extended json files.

install

npm install --save-dev grunt-json-extend

example

src

[
    {
        "foo": "bar"
    }
]

dest

[
    {
        "foo": "bar",
        "baz": "foobar"
    }
]

usage

module.exports = function(grunt) {
    grunt.initConfig({
        jsonExtend: {
 
            // add source json file here.
            src: './json/test-before.json',
 
            // add destination json file here.
            dest: './json/test-after.json',
 
            // write callback functions as array,
            // to extend your object's property.
            callbacks: [
                function( obj ){
                    // obj is each object from src.
 
                    var result = 'foo' + '+' + obj.foo;
 
                    // return object, you want to add for json file.
                    return {
                        "baz": result
                    };
                }
            ]
        }
    });
    grunt.task.loadTasks("tasks");
    grunt.registerTask( 'default', [ 'jsonExtend' ]);
};

Readme

Keywords

none

Package Sidebar

Install

npm i grunt-json-extend

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • kogai