Tests if the value at specified index has the type T.


bool is<bool>              (size_t index) const;

bool is<const char*>       (size_t index) const;
bool is<char*>             (size_t index) const;

bool is<double>            (size_t index) const;
bool is<float>             (size_t index) const;

bool is<signed char>       (size_t index) const;
bool is<signed int>        (size_t index) const;
bool is<signed long>       (size_t index) const;
bool is<signed short>      (size_t index) const;
bool is<unsigned char>     (size_t index) const;
bool is<unsigned int>      (size_t index) const;
bool is<unsigned long>     (size_t index) const;
bool is<unsigned short>    (size_t index) const;
bool is<signed long long>  (size_t index) const;   // <- may require ARDUINOJSON_USE_LONG_LONG
bool is<unsigned long long>(size_t index) const;   // <- may require ARDUINOJSON_USE_LONG_LONG

bool is<JsonArray>         (size_t index) const;
bool is<JsonObject>        (size_t index) const;


index: the index of the value in the array.

T: the type to test.

Return value

  • true if value at specified index matches the type T,
  • false if not


Different C++ types can store the same JSON value, so is<T>() can return true for several Ts. For example, is<float>() always returns the same value as is<double>() .

The table below gives the correspondence between the JSON type and the C++ types:

JSON type T
Floating point float, double
Integer int, short, long, long long
String const char*, char*
Boolean bool
Array JsonArray
Object JsonObject

Caution: is<float>() and is<double>() return true for integers too.


char json[] = "[\"pi\",3.14]";
StaticJsonBuffer<256> jsonBuffer;
JsonArray& array = jsonBuffer.parseArray(json);

bool firstIsString =<char*>(0); // <- true
bool secondIsFloat =<float>(1); // <- true

// but we could also use<T>(), like that:
firstIsString = array[0].is<char*>(); // <- true
secondIsFloat = array[1].is<float>(); // <- true

See also