diff options
author | Christian Hesse <mail@eworm.de> | 2024-12-25 22:22:30 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-12-25 23:04:50 +0100 |
commit | ef3ce7cc6c43b28e6a80345d9861775767ba86f4 (patch) | |
tree | 58ed397946136a678aaddadb70b3f609a0a2bc84 | |
parent | 8212bd6c95935f02335d7d774bd3115a2c071fb1 (diff) |
global-functions: $ParseKeyValueStore: support JSON as input
This used to require a key=value store, separated with commas. An
example for `netwatch-notify` is:
/tool/netwatch/add comment="notify, name=example.com" host=93.184.215.14;
Now JSON is supported as well, so you could use:
/tool/netwatch/add comment="{\"notify\":true,\"name\":\"example.com\"}" host=93.184.215.14;
Looks more clumsy here, but may be of help in more complex setups...
-rw-r--r-- | global-functions.rsc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/global-functions.rsc b/global-functions.rsc index 766e8a2..85818b4 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -919,6 +919,13 @@ # parse key value store :set ParseKeyValueStore do={ :local Source $1; + + :if ([ :pick $Source 0 1 ] = "{") do={ + :do { + :return [ :deserialize from=json $Source ]; + } on-error={ } + } + :if ([ :typeof $Source ] != "array") do={ :set Source [ :tostr $1 ]; } |