ArduinoJson: F.A.Q

How to insert a null?

There are two ways to serialize a null:

  • either set the value to (char*)0,
  • or set the value to RawJson("null")

For example, to generate the following JSON:

{"myValue":null}

you can write:

DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["myValue"] = (char*)0; // or (char*)NULL if you prefer
root.printTo(Serial);

See:

Fork me on GitHub