hunterex
hunterex

Reputation: 595

How to handle JSON key with dollar sign with jq at Powershell?

Here is the jq command like below: jq '.. |."$ref"? | select(. != null)' It works in jq player

How do I run this command in Powershell?

I want to get all returned values to a variable in PowerShell (list/array).

I have tried:

How to get this jq command to work in Powershell? Thanks

Upvotes: 0

Views: 1923

Answers (1)

knittl
knittl

Reputation: 265707

jq '.. |.\"$ref\"? | select(. != null)' works with PowerShell version 5.1.1941.1682 on Windows 10. Note the single quotes around the argument and the backslashes before the double quotes.

If it doesn't, create a text file with the jq program (the string inside the quotes) and then run jq -f program.jq. This avoids any quoting or escaping issues of your shell, you can write the jq program verbatim, just as you would on jq play.

NB: select(. != null) can be written more succinctly as select(values)

Upvotes: 0

Related Questions