json-schema-org / json-schema-org/website
🐛 Bug: getPartsOfJson fails to correctly parse valid JSON due to regex-based parsing
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 169
- Forks
- 484
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 6
Description
Describe the bug
lib/getPartsOfJson.ts
Problem
getPartsOfJson attempts to parse JSON using regular expressions and manual bracket counting.
This approach is unreliable and causes valid JSON to be parsed incorrectly in several edge cases.
JSON grammar cannot be safely parsed with regex, especially when strings contain escaped characters, commas, or brackets.
Steps To Reproduce
Steps to Reproduce
Pass the above JSON string to getPartsOfJson
Observe incorrect syntax parts or missing nodes
Expected Behavior
Expected Behavior
Valid JSON should always be parsed consistently
Strings containing {}, [], or , should not break parsing
Syntax parts should accurately reflect the JSON structure
Actual Behavior
Regex-based parsing fails on valid JSON inputs
Edge cases lead to incorrect parsing results
Screenshots
No response
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.
Research direction
Start by reading lib/getPartsOfJson.ts and reproducing the reported failures with valid JSON strings containing escaped characters, braces, brackets, and commas. Trace how syntax parts and nodes are produced, then verify that valid JSON consistently preserves its structure without those characters causing missing or incorrect results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100