Skip to content

🐛 Bug: Incorrect Bracket Filtering in Strings within getPartsOfArrayContent #1266

@Karan-Palan

Description

@Karan-Palan

Describe the bug

The getPartsOfArrayContent function in lib/getPartsOfJson.ts incorrectly counts brackets ({, }, [, ]) when they appear inside strings. This results in parsing errors where brackets inside strings are treated as part of the JSON structure.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Provide a JSON array like:
    [
      "{key:value}",
      "[nested]",
      "\"String with {brackets}\"",
      "true",
      123,
      null
    ]
  2. Pass it to the getPartsOfArrayContent function.
  3. Observe the incorrect parsing results where brackets inside strings are not ignored.

There is a TODO comment above this function mentioning the need to filter brackets inside strings. However, after reviewing the commit history of the file, it appears this task was never addressed. I am creating this issue as a reminder in case it was overlooked.

Expected Behavior

The function should ignore brackets inside strings and correctly parse the array values.

Screenshots

No response

Device Information [optional]

- OS:Ubuntu 24.04.1 LTS
- Browser:Firefox
- version:LTS

Are you working on this issue?

I would love to solve this if approved. Thanks!

Metadata

Metadata

Assignees

Labels

Status: AcceptedIt's clear what the subject of the issue is about, and what the resolution should be.Status: In ProgressThis issue is being worked on, and has someone assigned.🐛 BugIndicates that the issue is a bug or defect.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions