mercredi 23 septembre 2020

jq - combining multiple if conditions when keys/values are in different files

I have two keys in the license.json JSON file - :

{
  "visitsAnnualQuota": 
  "visitsQuota": 
}

I need to set them to value 0 if the value of one particular key - .numberOfVisits from a different JSON file - consumption.json equals to zero.

If the .numberOfVisits from consumption.json does not equal to zero, then the above two keys need to set to -1 and all other keys in the license.json file which have the value equal to 9223372036854776000 need to have that value replaced to -1.

What I am doing right now is to have a bash script, read the value of .numberOfVisits to a shell variable, and then have a case block for the variable equals or not to zero and for each condition have jq called with the appropriate filters.

My question - can all the above logic combined into a single jq call?

Aucun commentaire:

Enregistrer un commentaire