0.0.6 • Published 7 years ago

compare_json v0.0.6

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

compareJSON

Checks JSON files within a path for duplicate keys and if all files within the same sub directory have the same keys.

Usage

Here is an example call of compare_json:

const compareJSON = require('compare_json');
const path = 'lib/json'

compareJSON(path).then(function (jsonFaults) {
    console.log(jsonFaults);
}).catch(console.error);

Note:

Non JSON files will be ignored.

The object will contain { path: '/absolute/path/you/initially/passed/', duplicate: [], missing: [] } if an empty directory or a directory without JSON files is passed. Also the object will look the same if no faults are detected.

If something faulty is detected the object will look something like this:

{
    path: '/absolute/path/you/initially/passed/',
    duplicate: [{
        file: '/absolute/path/to/a/json/file/containing/duplicate/keys.json',
        duplicateKeys: [Array]
    }],
    missing: [{
        file: '/absolute/path/to/a/json/file/which/is/missing/keys/another/json/file/in/the/same/location/contains.json',
        missingKeys: [Array]
    }]
}

Grunt Plugin

grunt-compare_json