-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
How to remove quotes from the results? #1735
Comments
Check the jq manual! |
thanks! i find "-r" or "--raw-output" in the manual.. |
@pkoppstein that has to be one of the most unuseful comments in the history of github |
From the manual (version jq-1.5-1-a5b5cbe installed on ubuntu 16.04)
Would be useful to you if you're comparing the length of characters from an output to some other number. For instance, when using jq to find a UUIDv4 and checking its length to confirm it's 36 characters, |
FTR |
@lleeoo - Please note that the -r command-line option does work as it is intended to, in all extant versions of jq. In particular, when used in conjunction with |
Thank you, @pkoppstein. I understand that the behaviour is as intended, and FWIW I think it is the correct behaviour at the current stage. I just put that reference here for people who will come to the page via Google. I found this SE answer to be a great summary of the topic. The entire question discussion is useful. What I think might be helpful is if the string does not need quotes in CSV, then it shouldn't take them, but that is a nice-to-have. |
@sendtomoon thank you! |
That's really rude. I mean it's open source and all that but implementing something with so counter-intuitive approach and saying the users "RTFM" is just a very unpleasant user experience |
This is the search term I used on google:
Which showed this github issue as the second result. I fully understand that I should be RTFM. However when I have a deadline or any form of time constraint, or just can't be bothered, and knowing just one specific thing will solve my problem, github issues like these (or stackoverflow questions for that matter) help a lot. Thanks! |
I also came here through a popular search engine, well aware that the information I need can be found through the man page, but thinking I could find the answer faster through said search engine. IMO, this is the kind of thing that would fit much better i.e. in stackoverflow rather than as a github issue. Anyway, found the |
But... it wasn't conveyed in a rude way at all. A helpful pointer was given to where this kind of information is officially provided. If the flag were to change for any reason, the actual manual would be updated, but anyone visiting this thread would be none the wiser. |
Hold up. How is rude to take the time help a complete stranger with a friendly and accurate pointer? Give a man a fish and he eat for a day, teach him how to fish and you feed him for a lifetime. The way this issue thread played out everyone has 1) the answer to this specific answer right where you need it in a tight spot and 2) a general way of finding answers yourself. 🤷 |
Manuals should be SEO-ed. Then we would not have this problem! 😄 I think most devs usually just google something so simple to get a straight answer instead of trying to find it in the manual. This makes sense because they just want to get it done and google takes significantly less time. |
Actually, it's not that easy to locate the necessary option in the manual. I know that it's at the very beginning; but for a complete newbie of I speak for myself here: I had a wrongly written |
@sendtomoon Thank you for posting the answer here. I checked the man page first, but I would never have thought to look for the word "raw" in a 3,288-line help file. 😄 |
No, that one is. And it is also an undue and unnecessary ad personam.
|
friendly remark for those considering asking instead of searching: What you're saying to the contributors to FOSS software like jq is that you value their time so much less than your own, that you are willing to skip reading the documentation to take their time for free. Documentation they wrote, so you have something to refer to. Now, I'm not willing to point fingers here in terms of what is a useful or a polite comment and what could have been phrased differently, but people actively calling maintainers and contributors names in this issue should probably consider at least paying these folks industry-standard consulting rates for their time spent answering such non-issues. (@migralito, that means you; you're not only rude, but racist on top...) |
I have used command -r for this JSON and I am still getting this output with double quotes. See example below: input JSON ( $payload ) -> } bash.sh -> function load_json { dataset=$(echo "$payload" | jq --raw-output .dataset) echo "dataset -> $dataset" } OUTPUT -> dataset -> zip code As showed in the example, I get zip code without quotes but I can't eliminate double quotes in the zipcodes array. I need to read this information as a filter parameter for a SQL query in postgrest and I will need to pass it with single quotes. |
Try this which will iterate the array and output each string in the array separately, that way
If you want that and single quotes can fake it by doing something like:
But that will include an ending "," in the array... needs some more work to get rid of that |
The first answer says "check the manual". But this page is the top google result for me. |
@wader Thank you so much for your reply. At the end, I found a workaround using the command 'tr' from hash I drop the solution implemented below:
and the SQL query where I've used so:
The output given in this case is : zip_codes -> Hope it is useful for someone. |
@MECJUMP 👍 no problem, good to remember jq is not the solution to all problems... but almost :) |
me: Hey English isn't my first language and I'm just wondering what the word is for somebody who isn't very kind? |
I was doing something similar - this did it for me - keys with no quotes cat somefile.json | jq "keys" | jq -r ".[]" edit - easier way is below from @wader - tnx! |
@rondomondo Hi, you can add a |
I wish this worked with |
@lleeoo (three years later, but for the sake of completeness) To remove the quotes from the CSV output (at your own risk), you can use |
for example
jq .data
result : "hello"
I want to remove the double quotes in the result. What should I do?
The text was updated successfully, but these errors were encountered: