# keyExistsJson

Description: keyExistsJson cheatcode documentation

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/reference/cheatcodes/External/key-exists-json.mdx

{/* This document contains content copied/adapted from the Foundry Book (MIT licensed). See LICENSE in the parent directory. */}

### Signature

```solidity
// Check if a key exists in a JSON string.
vm.keyExistsJson(string memory json, string memory key) returns (bool)
```

### Description

Checks if a key exists in a JSON string.

### Examples

```solidity
string memory path = "./path/to/jsonfile.json";
string memory json = vm.readFile(path);
bool exists = vm.keyExistsJson(json, ".key");
assertTrue(exists);
```
