mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-03 12:44:50 +02:00
Add containsKey
@@ -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
|
||||
|
Reference in New Issue
Block a user