How to remove double-quotes in jq output for parsing json files in bash?

Chris F picture Chris F · Jun 20, 2017 · Viewed 69.3k times · Source

I'm using jq to parse a JSON file as shown here. However, the results for string values contain the "double-quotes" as expected, as shown below:

$ cat json.txt | jq '.name'
"Google"

How can I pipe this into another command to remove the ""? so I get

$ cat json.txt | jq '.name' | some_other_command
Google

What some_other_command can I use?

Answer

Charles Duffy picture Charles Duffy · Jun 20, 2017

Use the -r (or --raw-output) option to emit raw strings as output:

jq -r '.name' <json.txt