jq

jq: How to output quotes on raw output on Windows


Using raw output, I have to quote some values of the output.

For example,

echo [{"a" : "b"}] | jq-win64.exe --raw-output ".[] | \"Result is: \" + .a + \".\""

generates

Result is: b.

but how can I generate the following?

Result is: "b".

Unfortunately, it has to run on Windows, called from inside a CMD file.


Solution

  • You need to escape the slashes to escape a "

    $ echo [{"a" : "b"}] | jq-win64.exe --raw-output ".[] | \"Result is: \\\"\" + .a + \"\\\".\""
    Result is: "b".