Skip to content

Positive exponents are truncated when repairing incomplete JSON #230

Closed

Description

@mfurkanakinci

Version of the library

0.63.4, also reproduced on main at 0a7317e.

Describe the bug

Repairing a response with a missing closing brace changes a valid number with a positive exponent. 1e+10 becomes 1. In an array, the exponent becomes a separate string element.

How to reproduce

from json_repair import repair_json

print(repair_json('{"value": 1e+10', return_objects=True))
# {'value': 1}
print(repair_json('[1e+10, 2', return_objects=True))
# [1, 'e+10', 2]

Expected behavior

The results should be {'value': 10000000000.0} and [10000000000.0, 2]. Repairing the missing delimiter should preserve the number. Negative exponents such as 1e-10 already survive this repair.

I plan to add a focused fix and regression tests for object, array, and file input.

A tested fix is available on fix/positive-exponent-repair. This repository currently restricts PR creation to collaborators, so I could not open the corresponding upstream PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions