## `keyExists`

:::warning[Deprecated]
`keyExists` is being deprecated in favor of [`keyExistsJson`](/reference/cheatcodes/key-exists-json). It will be removed in future versions.
:::

### Signature

```solidity
function keyExists(string memory json, string memory key) external returns (bool);
```

### Description

Checks if a key exists in a JSON string.

### Parameters

| Parameter | Type     | Description                      |
|-----------|----------|----------------------------------|
| `json`    | `string` | The JSON string to search        |
| `key`     | `string` | The JSONPath key to look for     |

### Returns

| Type   | Description                              |
|--------|------------------------------------------|
| `bool` | `true` if the key exists, `false` otherwise |

### Examples

```solidity [test/KeyExists.t.sol]
string memory path = "./path/to/jsonfile.json";
string memory json = vm.readFile(path);
bool exists = vm.keyExists(json, ".key");
assertTrue(exists);
```

### Related Cheatcodes

* [`keyExistsJson`](/reference/cheatcodes/key-exists-json) - The non-deprecated version
* [`keyExistsToml`](/reference/cheatcodes/key-exists-toml) - Check if a key exists in TOML
* [`parseJson`](/reference/cheatcodes/parse-json) - Parse JSON values
