# json-dup-key-validator

> A json validator that has an option to check for duplicated keys

Latest version **1.0.3** (published 2021-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-dup-key-validator
pnpm add json-dup-key-validator
yarn add json-dup-key-validator
bun add json-dup-key-validator
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-02-06 |
| First published | 2016-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/json-dup-key-validator) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Jie Liu |
| Maintainers | jackyjieliu |
| Keywords | jsonvalidator, json, validator, validation |

## Links

- npm: https://www.npmjs.com/package/json-dup-key-validator
- Repository: https://github.com/jackyjieliu/json-dup-key-validator
- Issues: https://github.com/jackyjieliu/json-dup-key-validator/issues
- npm.io page: https://npm.io/package/json-dup-key-validator

## Dependencies (1)

- [backslash](https://npm.io/package/backslash.md) ^0.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-02-06
- 1.0.2 — 2017-04-18
- 1.0.1 — 2017-02-25
- 1.0.0 — 2016-05-22

## README

# json-dup-key-validator [![NPM version](https://img.shields.io/npm/v/json-dup-key-validator.svg)](https://www.npmjs.com/package/json-dup-key-validator) [![Build Status](https://travis-ci.org/jackyjieliu/json-dup-key-validator.svg?branch=master)](https://travis-ci.org/jackyjieliu/json-dup-key-validator)

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

## Install
`npm install json-dup-key-validator`
## Usage
```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);
```
## 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`

Default: `false`

Whether duplicated keys are allowed in an object or not

## .parse(jsonString, allowDuplicatedKeys)
Parses a json string and returns the parsed result. Throws error if the json string is not valid.
#### jsonString
Type: `String`

JSON string to parse
#### allowDuplicatedKeys
Type: `Boolean`

Default: `false`

Whether duplicated keys are allowed in an object or not

---
_Source: https://npm.io/package/json-dup-key-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
