Skip to content

nmccready/json-duplicate-key-handle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-dup-key-validator NPM version Build Status

A json handler that has an option to check for duplicated keys

Install

npm install json-duplicate-key-handle

Usage

var jsonHandler = require('json-duplicate-key-handle');

// Returns error or undefined if json is valid
jsonHandler.validate(jsonString, allowDuplicatedKeys);

// Returns the object and handle if duplicate key
jsonHandler.parse(jsonString, allowDuplicatedKeys);

API

.validate(jsonString, allowDuplicatedKeys)

Validates a json string and returns error if any, undefined if the json string is valid.

jsonString

Type: String

JSON string to parse

allowDuplicatedKeys

Type: Boolean|String

Default: false

Whether duplicated keys are allowed in an object or not

  • true || 'increment' true will behave identical to JSON.parse, increment will append duplicate keys by incrementing the field/key name

.parse(jsonString, allowDuplicatedKeys)

Parses a json string and returns the parsed result

jsonString

Type: String

JSON string to parse

allowDuplicatedKeys

Type: Boolean

Default: false

Whether duplicated keys are allowed in an object or not

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%