2.0.1 • Published 8 years ago

grunt-json-format v2.0.1

Weekly downloads
317
License
MIT
Repository
github
Last release
8 years ago

grunt-json-format

A Grunt Task for formatting JSON files.

Build Status NPM Release

Getting Started

# Add the module to your project
npm install grunt-json-format --save-dev
// Load the module in your Gruntfile
grunt.loadNpmTasks('grunt-json-format');

Of course, you'll need to be using Grunt

Usage

// Configure the task by providing a config.
'json-format': {
    test: {
        options: {
            indent: 4,
            remove: ['_comment']
        },
        files: [
            {
                expand: true,
                cwd: './test',
                src:  ['./json/test-1-*.json'],
                dest: './build/'
            },
            {
                expand: true,
                cwd: './test',
                src:  ['./json/test-2-*.json'],
                dest: './build/'
            }
        ]
    }
}
# Run the task
grunt json-format:test

Options

indent

Type: String or Number

Default: null

The indentation of the output.

Number indicated the number of whitespaces to use whereas a String will indicate the character to use (for example \t will use tab characters).

By providing null or 0, no indentation will be used and the output will essentially be minified.

remove

Type: Array

Default: []

The keys to remove from the output.

This is useful for removing comment keys like _comment.

Files

Check the Grunt Documentation on how to declare files and how Grunt parses them.

License

Copyright (c) 2014 Jahed Ahmed

Licensed under the MIT license.

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago