Mikrotik Script for JSON dump
This MikroTik function allows you to convert an array to JSON format. JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and for machines to parse and generate.
- MikroTik RouterOS device (7+)
- Basic understanding of MikroTik scripting
- Access to the MikroTik device either through Winbox, SSH, or Webfig interface
- Log in to your MikroTik device.
- Navigate to the Terminal.
- Create a System->script and paste the script into the Terminal.
# Script to dump the array to JSON
/import jsonDump.rsc
:put [$fJDump {"key"={k1=2;k2=125}; "key22"={k1=1;k2=80}; "7"={k1=0;k2=8080}}- Ensure that you have an array created in your MikroTik device.
- Modify the
arrayNamevariable in the script to match the name of your array. - Execute the script in the Terminal.
- Ensure that the array you are converting to JSON contains valid data.
- This script assumes that the array only contains string values. If your array contains other data types, you may need to modify the script accordingly.
This script is provided under the MIT License. For details, see the LICENSE file.
This MikroTik function was written by Svyatoslav Potyeyenko.
Feedback, issues, and contributions are welcome!