mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $ParseJson: return array as ... array 😜
No need to assemble the string here, just to split it again later.
This commit is contained in:
parent
fffe0a3b50
commit
9138c17f8c
1 changed files with 15 additions and 8 deletions
|
@ -719,26 +719,33 @@
|
|||
:local Val1 ($Input->($I + 1));
|
||||
:local Val2 ($Input->($I + 2));
|
||||
:if ($Val1 = ":") do={
|
||||
:set ($Return->$Key) $Val2;
|
||||
:set Skip 2;
|
||||
:set ($Return->$Key) $Val2;
|
||||
:set Done true;
|
||||
}
|
||||
:if ($Done = false && $Val1 = ":[") do={
|
||||
:local Tmp "";
|
||||
:local End;
|
||||
:local Last false;
|
||||
:set Skip 1;
|
||||
:set ($Return->$Key) ({});
|
||||
:do {
|
||||
:set Skip ($Skip + 1);
|
||||
:local ValX ($Input->($I + $Skip));
|
||||
:set End [ :pick $ValX ([ :len $ValX ] - 1) ];
|
||||
:set Tmp ($Tmp . "},{" . $ValX);
|
||||
} while=($End != "]");
|
||||
:set ($Return->$Key) ("{" . [ :pick $Tmp 0 ([ :len $Tmp ] - 1) ] . "}");
|
||||
:if ([ :pick $ValX ([ :len $ValX ] - 1) ] = "]") do={
|
||||
:set Last true;
|
||||
:set ValX [ :pick $ValX 0 ([ :len $ValX ] - 1) ];
|
||||
}
|
||||
:set ($Return->$Key) (($Return->$Key), $ValX);
|
||||
} while=($Last = false);
|
||||
:set Done true;
|
||||
}
|
||||
:if ($Done = false && $Val1 = ":[]") do={
|
||||
:set Skip 1;
|
||||
:set ($Return->$Key) ({});
|
||||
:set Done true;
|
||||
}
|
||||
:if ($Done = false) do={
|
||||
:set ($Return->$Key) [ :pick $Val1 1 [ :len $Val1 ] ];
|
||||
:set Skip 1;
|
||||
:set ($Return->$Key) [ :pick $Val1 1 [ :len $Val1 ] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue