-1

Thanks in advance for taking a look at this. I have constructed a working jq filter with the help of other Stack Overflow threads but I can't get it working in my windows terminal

Here it is directly from jqplay:

jq '.objects[ ] | "\(.id) \(.batch_fields.SJNB)"'

Here is what I have unsuccessfully tried thus far:

jq '.objects[ ] | "\(.id) \(.batch_fields.SJNB)"' file.json
jq ".objects[ ] | "\(.id) \(.batch_fields.SJNB)" file.json"
jq .objects[ ] | "\(.id) \(.batch_fields.SJNB) file.json

It's clear that it's a problem with quoting or not quoting and I can get more simple commands to work such as:

jq-win64.exe .objects[].id Row0.json

But I can't seem to crack the issue for the more complicated one.

Thanks, Jason

JasonO
  • 3
  • 1

1 Answers1

2

If you're running this in the windows command prompt, you have to use double quotes to quote your filter, there's no getting around it. Then from there, you just need to escape characters in your filter appropriately.

> jq ".objects[] | \"\(.id) \(.batch_fields.SJNB)\"" file.json
Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272
  • 1
    One way of getting around it is `jq -f some.jq some.json` and placing your jq expression in a file. – sshine Nov 26 '19 at 09:56
  • This worked! I will try the file version also. This seems to have an advantage because I could use the same command in windows and linux and not have to keep both versions around. Thanks to both of you so much! I feel bad that my question got down-voted because it was addressed and I couldn't find it. Thanks for taking the time to reply again! – JasonO Nov 26 '19 at 15:56