jshn: add json_get_keys()
[project/libubox.git] / sh / jshn.sh
index 1d9fc80..110892c 100644 (file)
@@ -182,6 +182,10 @@ json_add_boolean() {
        _json_add_generic boolean "$1" "$2"
 }
 
+json_add_double() {
+       _json_add_generic double "$1" "$2"
+}
+
 # functions read access to json variables
 
 json_load() {
@@ -201,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