Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Parsing Docs are Outdated #372

Open
Tracked by #3801
daweth opened this issue May 6, 2023 · 1 comment
Open
Tracked by #3801

JSON Parsing Docs are Outdated #372

daweth opened this issue May 6, 2023 · 1 comment

Comments

@daweth
Copy link

daweth commented May 6, 2023

The docs located here: https://book.getfoundry.sh/cheatcodes/parse-json

are completely outdated. The example code

string memory root = vm.projectRoot();
string memory path = string.concat(root, "/src/test/fixtures/broadcast.log.json");
string memory json = vm.readFile(path);
bytes memory transactionDetails = json.parseRaw(".transactions[0].tx");
RawTx1559Detail memory rawTxDetail = abi.decode(transactionDetails, (RawTx1559Detail));

results in an error

error[9574]: TypeError: Type bytes memory is not implicitly convertible to expected type string memory.
error[8015]: TypeError: Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but string provided.
@tariqkb
Copy link

tariqkb commented Oct 14, 2023

https://book.getfoundry.sh/cheatcodes/parse-json#how-to-use-stdjson

Follow the steps outlined before that code snippet. Notably you need to add using stdJson for string; to your contract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants