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

Print strings without quotes #250

Closed
phihag opened this issue Dec 20, 2013 · 15 comments
Closed

Print strings without quotes #250

phihag opened this issue Dec 20, 2013 · 15 comments
Labels

Comments

@phihag
Copy link
Contributor

phihag commented Dec 20, 2013

When I print strings, they are always surrounded with quotes:

$ echo '{"search":"jq!"}' | jq '@uri "http://www.google.com/search?q=\(.search)"'
"http://www.google.com/search?q=jq!"

(This is with jq 18e828f ). I'd like to feed this output into a program that expects URLs to be newline-separated and verbatim. How can I get the output without quotes, i.e.

http://www.google.com/search?q=jq!
@stedolan
Copy link
Contributor

jq -r (or jq --raw-output)

@phihag
Copy link
Contributor Author

phihag commented Dec 21, 2013

Thanks, no idea why I've missed that in the manpage. By the way, is there any reason why jq --help doesn't list the options, or is this simply a missing feature?

@phihag phihag closed this as completed Dec 21, 2013
@stedolan
Copy link
Contributor

Missing feature. jq --help needs a rewrite, it should have a couple of useful examples. I don't think a list of options would be the right thing, but what's there at the moment isn't terribly useful.

@socketpair
Copy link

socketpair commented May 10, 2018

Instead of this, someone should implement jq 'xxxxxx | to_raw_string'

@k001
Copy link

k001 commented Feb 12, 2019

Why is referenced to Elasticsearch this one @wgrzelak ?

@wgrzelak
Copy link

I have used this topic as an example of simplifying an output of jq command :)

@dotnetchris
Copy link

Thank you @stedolan

@userException
Copy link

jq -r (or jq --raw-output)

I am using fastlane to do some dynamic changes to my iOS app's property list file. The sybtax goes like this:

display_name: sh("jq -r .app_name ../billerConfig.json")

  • display_name is the property of fastlane, which changes the name of my app.
  • sh: signifies that we are trying to run a shell script in fastlane
  • Rest of the command is understandable

Now when I see my project, I see there is a huge white space and then next line inserted, at the end of the app name. I don't think this is the issue with jq but just asking here, if it could be ?

@smac89
Copy link

smac89 commented Dec 19, 2019

@userException See if this helps:

#1735 (comment)

@userException
Copy link

Using "chomp" worked for me: sh("jq -r '.appName' ../billerConfig.json").chomp

@vintnes
Copy link

vintnes commented Oct 23, 2020

@celesteking here's a fun fact: over 300 people subscribe to this entire issue board and just received that image in their work emails.

Another fun fact: many people are working remotely and regularly sharing their screens.

@celesteking
Copy link

What's done is done. I really like jq, just wanted to share my delightment with the usage of this tool. And it's not about the tool itself, absolutely not, but about the thorough documentation and the community. I've never had a problem looking up the usage examples and finding the right answer on google (either leading here, to issues section, or on SO).

Pressing the "like" button won't "subscribe" you to the issue, so it narrows down to just 9 ppl ;)

@wtlangford
Copy link
Contributor

Pressing the "like" button won't "subscribe" you to the issue, so it narrows down to just 9 ppl ;)

I see 317 watchers of the repo, but regardless of the number, it's still not appropriate. I've removed the image.

@4thel00z
Copy link

@socketpair
you can just use
jq <whatever> | cut -d '"' -f 2

@AQS-DTheuke
Copy link

If you have an array that you want to output as plain string you have to use:

jq '.[]' -r

or

jq 'map(.textPayload) | .[]' -r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests