jshn: add json_get_keys()
authorFelix Fietkau <nbd@openwrt.org>
Sat, 19 Oct 2013 22:00:42 +0000 (00:00 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 19 Oct 2013 22:00:42 +0000 (00:00 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
sh/jshn.sh

index b4bb1e13a8cc12e849d702a97fba1c06241d01ce..110892cba29ba2d9ee60e7742851cf37040a685b 100644 (file)
@@ -205,6 +205,15 @@ json_get_type() {
        eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
 }
 
+json_get_keys() {
+       local __dest="$1"
+       local _tbl_cur
+
+       json_get_var _tbl_cur "$2"
+       local __var="${JSON_PREFIX}KEYS_${_tbl_cur}"
+       eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
+}
+
 json_get_var() {
        local __dest="$1"
        local __cur