mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-13 03:24:28 +02:00
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...
This commit is contained in:
parent
8212bd6c95
commit
ef3ce7cc6c
1 changed files with 7 additions and 0 deletions
|
@ -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 ];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue