From ef3ce7cc6c43b28e6a80345d9861775767ba86f4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 25 Dec 2024 22:22:30 +0100 Subject: 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... --- global-functions.rsc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'global-functions.rsc') 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 ]; } -- cgit v1.2.3-70-g09d2