ArduinoJson: F.A.Q

How to know the type of a value?

JsonVariant, which is the type that hold the values in JsonArray and JsonObject, provides the method is<T>() that returns true if the value is of type T.


object["key"] = "value";
object["key"].is<const char*>(); // returns true
object["key"].is<int>(); // returns false
object["key"].is<JsonObject&>(); // returns false

array[0].is<const char*>(); // return false
array[0].is<int>(); // return true
array[0].is<JsonObject&>(); // return false

See issues #148, #175 and #213.

Fork me on GitHub