# json/top-level-interop

> Require the JSON top-level value to be an array or object

The first JSON specification, RFC 4627, only allowed an object or an array at the top of a document. Later ones allow any value, but some older parsers still reject a file that's just a string, a number, `true`, `false`, or `null`. Turn this rule on for files that such tools have to read.

{/* 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/top-level-interop": "error" },
  },
];
```

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

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

## Examples

Reported:

{/* bad */}

```json
"app"
```

{/* bad */}

```json
42
```

Not reported:

{/* good */}

```json
{ "name": "app" }
```

{/* good */}

```json
[1, 2, 3]
```
