-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Filter through command #71
Comments
You can use |
Thanks. Also appreciate you closed it, I would rather a repo I use have few open issues than a bunch of out of scope feature requests. I'll blog if I do anything interesting with my newfound knowledge of WithFunction! |
Hey @benatkin, did you end up using |
@noperator here is an example of a function that runs a shell command #101 (comment) but as usual with shell and exec, be careful |
That's perfect, thanks @wader. @lgfausak suggested in that same issue that one could:
If I understand that comment correctly, then it seems like I could:
I'm going to play around with that to test my understanding of this whole process. If you happen to see any obvious gaps in that approach, please let me know. |
@noperator Your welcome. There is no support for loading "native" modules as such at runtime, instead you can for example build your own version of the gojq cli tool with that function added. |
Loading extensions at runtime is general not easy to achieve with golang? I think if possible it would be very nice to implement new or special features to gojq as an extension in a separate file. To provide a proof-of-concept or try out something and gather feedback. gojq could stay close to upstream. Maybe extensions could be namespaced by default, so no collisions with future jq changes possible. |
That is my understanding also but i have no experience doing it. Read a bit about the Maybe if you want to experiment you could import gojq and build some bridge to Depending on what performance your looking for an alternative could be to mimic something like fastcgi? let an external process get calls as serialized JSON and respond with JSON? using the code i linked to above you can prototype such things like this: def _process_rpc($cmd): tojson | cmd($cmd) | fromjson;
def json_http($method; $url):
_process_rpc(["curl", "-X", $method, "-H", "Content-Type: application/json", "-d", "@-", "-o", "-", $url]);
{bla: 123} | json_http("GET"; "https://httpbin.org/anything") {
"args": {},
"data": "{\"bla\":123}",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Content-Length": "11",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "curl/7.84.0",
"X-Amzn-Trace-Id": "Root=1-63669f6d-17a435df1c8948ba322b588c"
},
"json": {
"bla": 123
},
"method": "GET",
"origin": "...",
"url": "https://httpbin.org/anything"
} |
It would be nice to be able to filter each value in an array or object through a shell command
There is an issue in jq, which is popular but hasn't yet made it into the library. Perhaps it would be a lot easier to implement with golang :)
jqlang/jq#147
The text was updated successfully, but these errors were encountered: