You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Return the value(s) that correspond to 'key'
vm.parseJson(string memory json, string memory key)
as well as
[JSON Encoding Rules](https://book.getfoundry.sh/cheatcodes/parse-json#json-encoding-rules)
We use the terms number, string, object, array, boolean as they are defined in the [JSON spec](https://www.w3schools.com/js/js_json_datatypes.asp).
A call to parseJson with json that has an object with an error in the object's name field, such as
An official JSON spec starts the object definition with
An object structure is represented as a pair of curly bracket tokens surrounding zero or more name/value pairs.
A name is a string. A single colon token follows each name, separating the name from the value.```
The error message returned should the term `name` or even better `json object name` instead of the overloaded and term `key`. Ideally, the documentation link to JSON spec should be corrected & the parseJson function 2nd parameter name would be improved.
I've forked and made a PR that adds the failing test. https://github.com/foundry-rs/forge-std/pull/421.
I did the fork & branch against forge-std as I'm new to solidity/forge and couldn't get the foundry/forge solidity tests to run.
The text was updated successfully, but these errors were encountered:
The error occurs while parsing a key of an object, expecting a string but getting an invalid value. The message is coming from an external library (serde_json), but I guess it could be preceded by "Failed parsing JSON: "
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (08a629a 2023-06-03T00:14:26.563741000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
The parseJson docs at https://book.getfoundry.sh/cheatcodes/parse-json#signature
contain
as well as
A call to parseJson with json that has an object with an error in the object's name field, such as
demonstrated in foundry-rs/forge-std#421
erroneously reports this as
The 2nd parameter to parseJson is called key (but probably should be called something like JSONPath or jq).
The JSON spec reference erroneously links to W3Schools.com (which should never be the linked to authoritatively as it's poaching the official w3c) instead of a true JSON spec, such as the official ECMA spec at https://www.ecma-international.org/publications-and-standards/standards/ecma-404/.
An official JSON spec starts the object definition with
The text was updated successfully, but these errors were encountered: