keyExists
is being deprecated in favor of keyExistsJson
. It will be removed in future versions.
// Check if a key exists in a JSON string.
vm.keyExists(string memory json, string memory key) returns (bool)
Checks if a key exists in a JSON string.
string memory path = "./path/to/jsonfile.json";
string memory json = vm.readFile(path);
bool exists = vm.keyExists(json, ".key");
assertTrue(exists);