-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
jq needs a library! #98
Comments
This is a bit of a dup of #12 :( |
This might not be so difficult... Looking at main.c the internals look very much like a decent API. The one issue is that there's some global state that needs to be moved into a context handle in order to make the API thread-safe and re-entrant. These are the global variables used to hold state outside of main.c: cbuiltins |
See pull request #109. |
Thank you! I'd definitely intended to get around to doing this at some point, glad that someone else has beaten me to it :) That looks like the right list of global variables, except cbuiltins can stay global (it's readonly and should be marked const). I haven't gotten around to reading through your pull rq yet, but at first glance it looks good. |
This means the .data and .bss sections are empty, a good thing in a shared library (see #98).
@stedolan with the current autotools setup, is it still possible to build as a library? |
No, there's no trace of it left. I've been meaning to find time to |
@nicowilliams that would be very much appreciated. I'm looking to write bindings for Go. |
+1 +1 +1 Especially @icholy on the Go bindings. |
@dtolnay, should this be reopened or a new issue to be created instead? Thanks! |
A library exists already. For example jq.py is built on it. The documentation is lacking but see C API: libjq for what is exported and public. |
Oops my bad, didn't realize we now have a binding library now. Thanks for the pointer. |
Until we have good docs I wouldn't say that the API is stable, though we're unlikely to make backwards-incompatible changes, really. |
Also, if someone sends a PR with docs for the API... |
A C library for jq would. be. awesome. Ditto Python, node/JS, ..., but a C library should be easier given that jq is already written in C.
This is really like XSLT/XPath for JSON, and simplified a great deal. I can do things with jq in a few characters that require multiple lines of Python/whatever, so I'm starting to resort to popen(). A library would be easier to use :)
The text was updated successfully, but these errors were encountered: