diff --git a/API-Reference.md b/API-Reference.md index f085e77..91598b4 100644 --- a/API-Reference.md +++ b/API-Reference.md @@ -36,6 +36,7 @@ Some parts have been simplified to be easier to understand, so if you look at th - [JsonObject::begin\(\) / JsonObject::end\(\)](#jsonobjectbegin--jsonobjectend) - [JsonObject::createNestedArray\(\)](#jsonobjectcreatenestedarray) - [JsonObject::createNestedObject\(\)](#jsonobjectcreatenestedobject) + - [JsonObject::containsKey\(\)](#jsonobjectcontainskey) - [JsonObject::get\(\)](#jsonobjectget) - [JsonObject::measureLength\(\)](#jsonobjectmeasurelength) - [JsonObject::measurePrettyLength\(\)](#jsonobjectmeasureprettylength) @@ -1000,6 +1001,39 @@ will print ``` +### JsonObject::containsKey() + +##### Description +Tests if a key exists in the `JsonObject`. + +##### Signature + +```c++ +bool containsKey(const char* key) const; +bool containsKey(const String& key) const; +bool containsKey(const std::string& key) const; +``` + +##### Arguments + +`key`: the key to test. + +##### Return value + +`true` if the key is present is the `JsonObject`; `false` if not. + +##### Example + +```c++ +StaticJsonBuffer<256> jsonBuffer; +JsonObject& root = jsonBuffer.createObject(); +root["city"] = "Paris"; + +bool hasCity = root.containsKey("city"); // true +bool hasCountry = root.containsKey("country"); // false +``` + + ### JsonObject::get() ##### Description