json-dup-key-validator
Version:
A json validator that has an option to check for duplicated keys
42 lines (31 loc) • 1.32 kB
Markdown
A json validator that has an option to check for duplicated keys
`npm install json-dup-key-validator`
```js
var jsonValidator = require('json-dup-key-validator');
// Returns error or undefined if json is valid
jsonValidator.validate(jsonString, allowDuplicatedKeys);
// Returns the object and throws error if any
jsonValidator.parse(jsonString, allowDuplicatedKeys);
```
Validates a json string and returns error if any, undefined if the json string is valid.
Type: `String`
JSON string to parse
Type: `Boolean`
Default: `false`
Whether duplicated keys are allowed in an object or not
Parses a json string and returns the parsed result. Throws error if the json string is not valid.
Type: `String`
JSON string to parse
Type: `Boolean`
Default: `false`
Whether duplicated keys are allowed in an object or not