Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
vavava
Contributor

How to handling "empty" string and replace them in jq

Hi ALL,

I got a setback while I want to got a string form "where-used" output.
The where-used output form show as below

1672035226974.jpg

and I guess it the method to judgment whether "unused-object" or not.
The value of "Total"
=0 >> the target object is "unused object", all array is empty.
≠0 >> the target object is not "unused object", there is some objects information in array.
then if I interesting others string , just like "type" in object or "rule name" in access-control rules: rule,
I try the command below

11672039661093.jpg

Is it possible to return a word just like "null" if the array is empty ?

and how to do that in one command line.

Regards and thanks, vavava

0 Kudos
2 Replies
_Val_
Admin
Admin

What happens if you try using the same search in SmartConsole and not through API?

 

0 Kudos
PhoneBoy
Admin
Admin

As near as I can tell, this isn’t possible and you have to do something like: https://stackoverflow.com/questions/53135035/jq-returning-null-as-string-if-the-json-is-empty

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events