Skip to content

Commit 705263c

Browse files
authored
feat: add new serializeJson cheatcode to the Vm and to StdJson (#453)
1 parent 1d9650e commit 705263c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/StdJson.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ library stdJson {
8989
return vm.parseJsonBytesArray(json, key);
9090
}
9191

92+
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory) {
93+
return vm.serializeJson(jsonKey, rootObject);
94+
}
95+
9296
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory) {
9397
return vm.serializeBool(jsonKey, key, value);
9498
}

src/Vm.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ interface VmSafe {
309309

310310
// Serialize a key and value to a JSON object stored in-memory that can be later written to a file
311311
// It returns the stringified version of the specific JSON file up to that moment.
312+
function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
312313
function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
313314
external
314315
returns (string memory json);

0 commit comments

Comments
 (0)