Available in JANOS 1.8.
The JMP protocol shares the messaging JSON structure that is used by the DCP (Dynamic Configuration Page) and the web-socket protocol but on port 9220, by default.
To make processing easier we wrapped the JSON message in a two element JSON Array.
[ number, object ]
Where number is the size in bytes/characters of the JSON object that follows.
Doing this relieves us of needing to count braces to see when an entire JSON message was received. To parse the structure we can do the following:
- Look for the opening ‘[‘.
- Then process numeric values until a ‘,’ is found. White-space is ignored.
- White-space is again ignored and N bytes are read.
- Finally remaining white-space is ignored and the trailing ‘]’ confirmed.
If the numeric value is invalid, the comma missing or the trailing ‘]’ bracket not found, the entire message is to be ignored. The extracted JSON Object can then be validated as well.