From f79ba55637169f9e05a51f6f8c24e0543c707458 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 17 Jul 2019 16:27:21 +0200 Subject: global-functions: add $ParseKeyValueStore --- global-functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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; +} -- cgit v1.2.3-70-g09d2