-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python Integration #84
Comments
You can execute any command line application from Python using import subprocess
broken_file = 'broken.json'
# if jsonrepair is installed globally via `npm install -g jsonrepair`
repaired_json = subprocess.check_output(['jsonrepair', broken_file], shell=True).decode('UTF-8')
# or, if jsonrepair is installed locally:
# repaired_json = subprocess.check_output(['node', './node_modules/jsonrepair/bin/cli.js', broken_file], shell=True).decode('UTF-8')
print(repaired_json) In this case it requires |
I tried to use jsii but couldn't get it fully working. You can have a look at my fork. After some small changes I got it to generate a Python library which I can successfully install in a virtual environment but when I try to import jsonrepair I get the error below. Maybe we can get it working somehow, because then it would be possible to generate jsonrepair for .NET, Golang, Java and Python.
|
The missing .jsii file already has an issue here. |
I have no clue about |
@josdejong You are right. It looks like it explicitly only supports classes. So it would probably be necessary to turn the jsonrepair prototype into a class, which is a bit of work, but on the other hand it would allow lots of people using different languages to repair JSON without having to either port this library to another language or run it as a subprocess, which isn't possible in some environments. |
If it is possible I would like to take a crack in helping do that. I think it would be great to be able to integrate this into code itself with other languages. Especially from a data science perspective. |
Would be nice to work out an experiment to see how to get this working in other environments. I have to say, I have no idea how mainstream |
I know jsii because Amazon created it to make the AWS CDK, which works really well. What I like about jsii is that it comes with a reference that includes a detailed specification on what people have to do to add support for more languages. Because of Amazon's backing I expect jsii to be well maintained for at least the next five years and it should support more languages than .NET, Golang, Python and Java in the future, for example there are already open issues for Ruby and Rust support. Also the Java target pretty much allows any language running in the JVM to use a library implemented with jsii. There is also a list of more transpilers here but it seems they forgot jsii. |
I ported jsonrepair to Python because I needed a quick solution, see this gist. The test suite passes 100% but better don't rely on the correctness of the code. I also won't update the code in the future, because we should instead focus on generating the code for other languages. |
I have been using JSONRepair via a Linux command line. I would like to use it with python, however, I have not been able to despite various attempts. Could you provide some guidance?
Thank you in advance
The text was updated successfully, but these errors were encountered: