Created
July 13, 2022 08:25
-
-
Save khaliqgant/2c15dc351f9cfd338485da8919254af7 to your computer and use it in GitHub Desktop.
[JQ Fallback Value] Fallback Value If Not Available #jq #cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CPU_LIMIT=$(echo "$customer_line" | jq -r '.cpu_limits.foo // 0') | |
MEMORY_LIMIT=$(echo "$customer_line" | jq -r 'if has("memory_limits") then .memory_limits.foo else 0 end') | |
# https://stackoverflow.com/questions/56555155/get-or-default-function-in-jq/56555442#56555442 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment