-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow users to specify jq options #30
Comments
They could be any named arguments in the |
hadn't tried it yet, just tried now, nothing works yet, an eg? |
Why would it work yet? :) |
im confused |
Me too :) My point was only the interface; that e.g.
I guess the
|
I guess you need to actually allow for the flasgs to passed along to the actual |
I can make the changes to the |
Was confused as I thought you were suggesting it should work now. But I figured it shouldn't. Right, we need to allow flags to be used. I imagine there's a way to hook into options via the C API, any thoughts @richfitz We could use a separate function like:
I don't think this needs to happen before cran push, but perhaps it does if it means a change to how |
Right. I guess the dsl could use a So, e.g. (jso
%>% something
%>% something_else
%>% flags("--sort-keys")
)
# or
jso %>% jq("something something_else", flags = list("--sort-keys")) I think it might get messy if we need to have low-level |
I vote for a separate function. Let's wait to see what rich says about hooking into the C API |
Will need a bit of adjustments, I think, not that's impossible; but we need to assess whether it's worth it.. also it's not as low-level-ish ;) |
Sure, I'll have a look - perhaps this week. Looks like sort-keys becomes the
|
(bear in mind though that the only connection between the command line interface and libjq is the implementation details in jq's main.c) |
OK, so that's done at the low level:
in colour on mac terminal (not Rstudio until they get ANSI colouring). I'm not sure how you want to mix that in with the DSL stuff; perhaps it goes in query_from_dots, perhaps it goes through things like do? It's late here so I don't want to break it! |
Thanks @richfitz |
@richfitz Any thoughts on how to update flags methods to implement the remainder of the jq flags? I'm not quite sure from looking at main.c how to do the remainder of the flags, main.c has https://github.com/ropensci/jqr/blob/master/src/jq/main.c#L111-L127 but those are a subset of all the flags. maybe some flags we can't use in R |
Those flags are used only within |
Ah - how were you able to do the 4 flags you implemented then? |
Those are (I think) just flags to Lines 188 to 199 in e92060a
|
thanks , hmm, doesn't seem like all the flags in the docs are in that file |
I think different entry points in jq have different sets of flags. Or I'm confused about what part of the docs you are seeing different sets of flags, perhaps 🎏 🇨🇦 |
the flags listed here https://stedolan.github.io/jq/manual/#Invokingjq |
yeah, I think that those are all doing things in |
okay, blegh |
An example of an option that'd be nice is x <- c('[1,2,3]','[4,5,6]')
## want: [1,2,3,4,5,6]
jq(x, 'flatten', .options = list('--slurp')) Is there another easy way to combine (an arbitrarily-long collection of) arrays without the slurp option? |
agree, |
thanks for the upvote on this, will try to get it sorted |
The easiest way (that I've come up with) to mimic the jq_slurp <- function(x) sprintf("[%s]", paste0(x, collapse = ","))
x <- c('[1,2,3]','[4,5,6]')
x %>% jq_slurp %>% jq('flatten') This is a language-specific (i.e. R-specific) solution, however, and one of the advantages of jq bindings is the common filter string language shared across different platforms, languages, etc. Though worth mentioning that I think jqr is already great and has drastically simplified my parsing/manipulation of JSON documents, so thanks! |
right, there is that solution, glad at least something works. Glad jqr is already helping you out! hopefully we'll get this sorted soon |
see the flags under https://stedolan.github.io/jq/manual/#Invokingjq section - @richfitz do you know if this is possible?
Some of them I think only make sense on the command line outside of R, but I think some could be used, e.g.,
--sort-keys
The text was updated successfully, but these errors were encountered: