Skip to content
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

Query string keys and values as json dictionary #120

Closed
grimnight opened this issue Apr 9, 2023 · 4 comments
Closed

Query string keys and values as json dictionary #120

grimnight opened this issue Apr 9, 2023 · 4 comments

Comments

@grimnight
Copy link

It would be useful to get query string keys and values as dictionary in --json output.

@havbon
Copy link
Contributor

havbon commented Apr 9, 2023

I am noticing now that '--get' doesn't really do anything when used with '--json' no warning or anything, we just get the json output.

But the feature you are referring to is already implemented, called "params":
image

Or did you mean to suggest that this command should exclusively produce a JSON output of {query} and {path}?

@emanuele6
Copy link
Collaborator

emanuele6 commented Apr 9, 2023

If you want the query in the json output to be an object, you can just use |jq '.[].params |= from_entries'.

--json outputs an array of key-value pairs, because queries can contain multiple entries with the same key, and the order of entries may be meaningful. This is similar to what other libraries that parse query strings do.

It would be more limiting if trurl outputted the query directly as an object.

@grimnight
Copy link
Author

I was using v0.3. I just tried the head and it does have params. Also thank you for the jq snippet, it provides what I need.
I think this issue can be closed, unless.

@bagder
Copy link
Member

bagder commented Apr 9, 2023

Thanks, yes I think the existing functionality + the command line tricks form above offers what was asked.

@bagder bagder closed this as completed Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants