How to output raw data from JQ
To output raw data from JQ, you can use the -r
option. This is particularly useful when you want to extract and display data without quotes or escape characters.
For example, given the following JSON input:
{
"code": "import datetime\nnow = datetime.datetime.now()"
}
You can use the command:
jq -r '.code' input.json
This will output:
import datetime
now = datetime.datetime.now()