Skip to content

[Bug]: Fix missing opening #233

Closed
Closed

Description

@trubens71

Version of the library

0.63.5

Describe the bug

This looks potentially very useful, thank you. For me it fell at the first hurdle of not repairing a missing opening "{".

How to reproduce

import json
import json_repair

bad_json = """
    "a": 1
}
"""

print(json_repair.loads(bad_json, logging=True))

try:
    json.loads(bad_json)
except json.JSONDecodeError as e:
    print(e)

returns:

('', [])
Extra data: line 2 column 8 (char 8)

Expected behavior

Ideally I would like json_repair to be able to fix a missing opening "{" in the same way it can fix a missing closing "}".

At a minimum should it not throw an exception in the way that a standard json.loads() does?

Activity

  1. mangiucugna commented on Oct 9, 2026

    @mangiucugna
    Owner

    Hi, this is a bit of a demonstration of the limits of a LL(1) parser as it makes it impossible to fix missing opening braces as a general case.
    I have pushed a fix that will recover a subset, but a general solution is architecturally impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions