mangiucugna/json_repair

File input flag

Closed this issue · 2 comments

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.

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.

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

  • implemented the drop-in replacement for json.load()
  • added a new function from_file() that take a file path as string
    To respect the behavior of the json library no exceptions are managed in the library but left to the caller

Thanks again for the contribution and ideas!