Search code examples
command-linejqquoting

jq reading filter from a file results in Invalid Syntax Error


filter.jq ".security = {hideVersionStringsWhenNotLogged: true}"

When trying to apply the filter, jq --from-file filter.jq a.json

encountering the following error jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Unix shell quoting issues?) at , line 1

tried all combinations of single and double quotes to no avail. Any suggestions? Thx


Solution

  • If you want the filter to be read from a file, do not enclose it in the quotation marks that are needed if the filter is specified on the command line.

    So the contents of your filter.jq file could look like this:

    .security = {hideVersionStringsWhenNotLogged: true}