Page 1 of 1
Feature Request: native JSON parsing function
Posted: Fri Jul 12, 2024 1:35 pm
by rossigee
Because everyone having to include huge swathes of unsupported third-party RouterOS functions to do such a common task is not a good look
I'm probably not the only one that would really appreciate first-class support for parsing JSON objects in RouterOS scripts.
Thanks, guys!
Re: Feature Request: native JSON parsing function [SOLVED]
Posted: Fri Jul 12, 2024 4:19 pm
by tdw
Mikrotik added :serialize and :deserialize commands in v7 which support JSON. I've not tested to see if it handles nested arrays.
Re: Feature Request: native JSON parsing function
Posted: Sat Jul 13, 2024 1:46 am
by Larsa
Yes, it does. Look for @Amm0's detailed explanations and examples on the matter.
Re: Feature Request: native JSON parsing function
Posted: Sat Jul 13, 2024 6:14 am
by rossigee
Brilliant! Thanks. Not sure why I didn't spot this in the docs earlier.
Re: Feature Request: native JSON parsing function
Posted: Mon Jul 15, 2024 8:52 pm
by Amm0
I have an example of using :serialize/:deserialize with /tool/fetch for the pushover app's JSON API here:
viewtopic.php?t=136256#p1083224
The approach work for most JSON API with a change of the URL used inside the function and different array of data provided.