JSON, short for JavaScript Object Notation, is a lightweight format for data exchange. JSON is a subset of the literal notation JavaScript object that does not require the use of XML. The simplicity of JSON has led to their widespread use, especially as an alternative to XML in AJAX. One of the supposed advantages of JSON over XML as a data exchange format in this context is that it is much easier to write a parser JSON. In JavaScript, JSON text can be analyzed using the procedure eval(), which has been fundamental to JSON has been accepted by the AJAX developer community because JavaScript ubiquitous on almost any web browser.
Every time there is more support for JSON using third party packages. The list that support these packages are: ActionScript, C, C++, C#, ColdFusion, Common Lisp, Delphi, E, Eiffel, Java, JavaScript, ML, Objective-C, Objective CAML, Perl, PHP, Python, Rebol, Ruby, Lua and Visual FoxPro.
The above definition is taken from Wikipedia and taking into account that JSON as a format is booming in the world of Web Services, Roomba Wi-fi Remote can also be accessed through this XML type of coding with roomba.xml and rwr.xml but with JSON format.
JSON files are updated such an XML: values are updated every 500ms (interesting for measuring Distance and Angle).
We have explained several times that the best way to read all the sensors is using the Transparent Mode or Gateway. Remember that it must be done taking into account the Full Mode and Safe Mode described in the specification SCI iRobot Roomba.
roomba.json
The file containing the information in JSON format is roomba.json. This file can be accessed from http://Roomba_Wi-fi_Remote_IP/roomba.json and has exactly same roomba.xml data: A structure called “response” with rX children. One rX for each sensor has a field called “name” defining the iRobot Roomba SCI specification. The field “value” is the last updated value from the automated process of Roomba Remote Wi-fi.
In the next lines you can find the structure of this file:
{ "response": { "r0": { "name": "Bumps Wheeldrops", "value": "VALOR" }, "r1": { "name": "Wall", "value": "VALOR" }, "r2": { "name": "Cliff Left", "value": "VALOR" }, "r3": { "name": "Cliff Front Left", "value": "VALOR" }, "r4": { "name": "Cliff Front Right", "value": "VALOR" }, "r5": { "name": "'Cliff Right'", "value": "VALOR" }, "r6": { "name": "Virtual Wall", "value": "VALOR" }, "r7": { "name": "Motor Overcurrents", "value": "VALOR" }, "r8": { "name": "Dirt Detector - Left", "value": "VALOR" }, "r9": { "name": "Dirt Detector - Right", "value": "VALOR" }, "r10": { "name": "Remote Opcode", "value": "VALOR" }, "r11": { "name": "Buttons", "value": "VALOR" }, "r12": { "name": "Distance", "value": "VALOR" }, "r13": { "name": "'Angle'", "value": "VALOR" }, "r14": { "name": "Charging State", "value": "VALOR" }, "r15": { "name": "Voltage", "value": "VALOR" }, "r16": { "name": "Current", "value": "VALOR" }, "r17": { "name": "Temperature", "value": "VALOR" }, "r18": { "name": "Charge", "value": "VALOR" }, "r19": { "name": "Capacity", "value": "VALOR" } } }