# json/no-duplicate-keys

> Disallow duplicate keys in JSON objects

When an object has the same key twice, `JSON.parse` keeps the last value and silently drops the others. Someone reading the file may only notice the first one. It's usually left over from a merge or a copy and paste.

An escape sequence counts as the character it stands for. In JSON5, `a`, `'a'`, and `"a"` are the same key.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. It needs an ESLint config that says which files are in the language:

{/* skip */}

```js eslint.config.js
import json from "@eslint/json";

export default [
  {
    files: ["**/*.json"],
    plugins: { json },
    language: "json/json",
    rules: { "json/no-duplicate-keys": "error" },
  },
];
```

It also works with `json/jsonc` and `json/json5`.

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}

```json
{
  "name": "app",
  "private": true,
  "name": "server"
}
```

{/* bad */}

```json5
{
  port: 3000,
  "port": 8080,
}
```

Not reported:

{/* good */}

```json
{
  "name": "app",
  "author": { "name": "Ada" }
}
```
