aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-07-17 16:27:21 +0200
committerGravatar Christian Hesse <mail@eworm.de>2019-07-17 16:27:21 +0200
commitf79ba55637169f9e05a51f6f8c24e0543c707458 (patch)
tree5ef1db47f802bf30b7c371d94abcc233626d0465
parent16f04ee7ee83755b7405835d343f9e056986173b (diff)
global-functions: add $ParseKeyValueStore
-rw-r--r--global-functions16
1 files changed, 16 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index b8afcd4..00eb0c9 100644
--- a/global-functions
+++ b/global-functions
@@ -226,3 +226,19 @@
}
:return true;
}
+
+# parse key value store
+:global ParseKeyValueStore do={
+ :global CharacterReplace;
+
+ :local Source $1;
+ :if ([ :typeof $Source ] != "array") do={
+ :set Source [ :tostr $1 ];
+ }
+ :local Result [ :toarray "" ];
+ :foreach KeyValue in=[ :toarray $Source ] do={
+ :set KeyValue [ :toarray [ $CharacterReplace $KeyValue "=" "," ] ];
+ :set ($Result->($KeyValue->0)) ($KeyValue->1);
+ }
+ :return $Result;
+}