Skip to content
This repository has been archived by the owner. It is now read-only.
A Grunt Task for formatting JSON files.
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tasks
test
.gitignore
.jshintrc
.npmignore
.travis.yml
LICENSE
README.md
gruntfile.js
package.json

README.md

grunt-json-format

Build Status NPM Release Patreon

A Grunt Task for formatting JSON files.

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 indicates 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

See the LICENSE file.

You can’t perform that action at this time.