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

File input flag #21

Closed ajmeese7 closed 6 months ago

ajmeese7 commented 6 months ago

Is your feature request related to a problem? Please describe. I'd prefer to be able to pass a file name to the function and have it automatically read the content and load it into the function, rather than implementing the logic myself.

Describe the solution you'd like I'm willing to implement this in a PR using argparse if that's good with you, it will simplify my use case in which the Python library is programatically invoked from a Bash file.

mangiucugna commented 6 months ago

Hi! Feel free to push a PR for this, I think it should be implemented as a new function called "load_file" in which the file is read and then repair_json is called. Of course all the repair_json params should be exposed as well.

mangiucugna commented 6 months ago

Hi, in the end I went in a sligthly different direction and done two things:

Thanks again for the contribution and ideas!