json-schema-org / json-schema-org/website
🐛 Bug: JSON parsing bug: Incorrect handling of backslash-escaped quotes
@Adityakk9031 is already working on this.
Since Feb 15, 2026.
- Dominant language
- HTML
- Stars
- 169
- Forks
- 484
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 6
Description
Describe the bug
Describe the bug
The custom JSON parser (implemented in lib/getPartsOfJson.ts) incorrectly identifies string boundaries when a string ends with an escaped backslash.
The parser uses the regex /(?<!)"/g to find the closing quote of a string. This logic is flawed because it assumes any backslash immediately preceding a quote escapes that quote. However, in JSON, a backslash can itself be escaped.
For example, in the valid JSON string "slash: ", the first backslash escapes the second, and the following quote is the closing quote. Because the current regex sees a backslash before the quote, it fails to match it as the end of the string, causing the syntax highlighting and path detection to break for the entire remainder of the code block.
Steps To Reproduce
1.) Open any markdown file in the project (e.g., pages/understanding-json-schema/basics.md).
2.) Add a JSON code block that includes a trailing escaped backslash:
json
{
"bad_string": "backslash: \",
"next_key": "this will be broken"
}
3.) Run yarn dev and navigate to that page.
4.) Observe: The syntax highlighting "leaks" out of the first string. The comma, the second key, and the rest of the block will all be colored as if they were still part of the first string.
Expected Behavior
The parser should correctly handle parity for escape sequences. A quote is only escaped if it is preceded by an odd number of backslashes.
Screenshots
Normal :-
Buggy :-
Device Information [optional]
- OS:
- Browser:
- version:
Are you working on this issue?
Yes
Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.