forge-std
forge-std copied to clipboard
escaped characters in json are not parsed correctly
Repro:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {stdJson} from "forge-std/StdJson.sol";
import "forge-std/Test.sol";
contract JsonTest is Test {
function testEscapedQuotes() public {
string memory json = '{"foo":"quotation mark: \'\\"\' and backslash: \\\\"}';
assertEq(stdJson.readString(json, ".foo"), 'quotation mark: \'"\' and backslash: \\');
}
}
The test passes with b4f121555729b3afb3c5ffccb62ff4b6e2818fd3 but fails with f8e700ed5d605f53f2194dc8df05a0bc3a7c1e43
[FAIL. Reason: Assertion failed.] testEscapedQuotes() (gas: 19525)
Logs:
Error: a == b not satisfied [string]
Expected: quotation mark: '"' and backslash: \
Actual: quotation mark: '\' and backslash: \\