The json module doesn't provide any functions to retrieve data from
within JSON types, requiring users to call jq (or other parsers)
directly.
This commit adds the json_object_get() function, which allows the user
to retrieve the value of a field in a JSON object.
return 0
}
+json_object_get() {
+ local object="$1"
+ local field="$2"
+
+ local value
+
+ if ! value=$(jq -e -r ".$field" <<< "$object"); then
+ return 1
+ fi
+
+ echo "$value"
+ return 0
+}
+
json_array() {
local args=("$@")