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 b4bb1e1..110892c 100644 (file)
@@ -205,6 +205,15 @@ json_get_type() {
        eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
 }
 
        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
 json_get_var() {
        local __dest="$1"
        local __cur