Jump to content

So I have a json file that when used with a jq filter that outputs true if it is a hit, and null if it is not a hit.

 

the filter looks like this and returns this

https://hastebin.com/copinavopa.scala 

 

How do I use -e to retrieve the comments which are a hit, and not the ones that are not a hit?


i can think of some psuedo code in java: (which doesn't use -e, but i know there is a more elegant solution with -e, e.g using && after the command)


for(int j = 0; j<fileCarriageReturnLength.length(); j++){

if((jq .messages[][].hit[j] test.json )== "true"){ //the hit[j] isn't real code, i don't know how to extract specific entries from the json data

jq .messages[][].hit[j] > hits.txt//this gets the jth index which should be true and puts it in the hits.txt file

}

}

 

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
https://linustechtips.com/topic/934249-jq-filter-question/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×