json-schema-org / json-schema-org/website

🐛 Bug: getPartsOfJson fails to correctly parse valid JSON due to regex-based parsing

Open
#2,028 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛 Bug Status: Triage
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.