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
Any interest in implementing .[] in interactive mode? #305
Comments
Yes, this is due to the fact what path is not a freeform JavaScript expression. It's a path of a cursor in JSON. I have an idea to add full support arbitrary JS expressions in future as well. One think I need to figure out, how to do argument splitting. Now fx relays on shell args splitting: fx '.[].foo' func 'x => x.length' How this string will be represented in a single string? Same with quotes? But this is ugly solution. With
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When viewing JSON in interactive mode, I'd love to be able to dig into arrays of objects by doing
.[]
. For example, in regular processing mode, I can pass a filter to fx on a top level array of objects like the example below, and get back a list of emails. So using this commandcurl "https://jsonplaceholder.typicode.com/comments" | fx '.[].email'
will process JSON like thisinto a result like this
But I can't achieve the same thing in interactive mode. If I try typing
.[].email
, as soon as I type the second dot, it clears my prompt and refuses to dig into the array. Doing.[0].email
works but only gives the first email.Would this be a PR that you would support? I'm not familiar enough with the codebase to make this change myself yet, but if this is a change you would allow, I could try to start familiarizing myself to work through opening a PR.
Also if so, are there contribution docs anywhere? I couldn't find them. Thanks!
The text was updated successfully, but these errors were encountered: