Quantcast
Viewing all articles
Browse latest Browse all 524

Conditional if/then/else for JMESPath?

Am trying to do a simple if/then/else using JMESPath

For example: 'if the input is a string, return the string, else return the "value" property of the input'. An input of "abc" would return "abc". An input of {"value":"def"} would return "def"

With jq this is easy: if .|type == "string" then . else .value end

With JMESPath, I can get the type

type(@)

or the input:

@

or the value property:

value

but I have not found a way to combine them into an if-then-else. Is there any way to do this?


Viewing all articles
Browse latest Browse all 524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>