mangiucugna / json_repair

A python module to repair invalid JSON, commonly used to parse the output of LLMs
https://pypi.org/project/json-repair/
MIT License
826 stars 48 forks source link

[Bug]: trailing comma gets added to field value when it's the last field #77

Closed pchalasani closed 1 week ago

pchalasani commented 1 week ago

Version of the library

0.29.8

Describe the bug

{

key: { 
   "a": b, 
   "c": d e, 
   "f": g h k,
     }, 
}

produces:

{
    "key": {
        "a": "b",
        "c": "d e",
        "f": "g h k,"
    }
}

Notice the last field "f" gets value "g h k," (with comma included), but I expected "g h k".

This was fine in 0.29.4

Playground link

How to reproduce

see above

Expected behavior

see above

mangiucugna commented 1 week ago

Thanks for reporting, I fixed the regression and added it to the tests. I will release now.