JSON

{
   "a":123,
   "b":"testing",
   "c":
       [
           1,
           2,
           3
       ],
   "d":10.333,
   "e":false,
   "f":
       {
           "g":"Call me \"John\"",
           "h":-0.78
       }
}

Since 0.6.1:

JSON is a standard for transmitting data in a text-based format. It's often used on Particle devices for placing multiple pieces of data in a single publish, subscribe, or function call. It's more flexible than formats like comma-separated values and has well-defined methods for escaping characters safely.

The Particle JSON library is based on JSMN for parsing and also includes a JSON generator/writer. It's lightweight and efficient. The JSMN parser is built into Device OS so it doesn't take up additional application RAM, however the wrapper library is included within the user application firmware binary.

  • The JSON encoded data consists only of 7-bit ASCII characters. Control characters are escaped.
  • There are types of data for bool, int, double, string, object, and array.
  • Objects and arrays can contain nested objects and arrays, as well as primitive types (bool, int, double, string).
  • There is no binary blob in JSON, you need to encode the data in something like Base64 or hex encoding.
  • You can't encode circular structures with JSON.