mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-03 12:44:50 +02:00
Updated API Reference (markdown)
@@ -737,12 +737,59 @@ JsonObject& object2 = jsonBuffer.parseObject(json);
|
||||
```
|
||||
|
||||
|
||||
### JsonObject::begin() / JsonObject::end()
|
||||
|
||||
##### Description
|
||||
Returns an iterator that can be use to get all key-value pairs in the object.
|
||||
|
||||
##### Signatures
|
||||
|
||||
```c++
|
||||
JsonObject::iterator begin();
|
||||
JsonObject::iterator end();
|
||||
JsonObject::const_iterator begin() const;
|
||||
JsonObject::const_iterator end() const;
|
||||
```
|
||||
|
||||
##### Return value
|
||||
A forward iterator pointing to a `JsonPair`, which itself contains two members `key` and `value`.
|
||||
|
||||
##### Example
|
||||
|
||||
```c++
|
||||
char json[] = "{\"first\":\"hello\",\"second\":\"world\"}";
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(json);
|
||||
|
||||
// using C++98 syntax:
|
||||
for (JsonObject::iterator it=root.begin(); it!=root.end(); ++it) {
|
||||
Serial.println(it->key);
|
||||
Serial.println(it->value);
|
||||
}
|
||||
|
||||
// using C++11 syntax:
|
||||
for (auto kv : root) {
|
||||
Serial.println(kv.key);
|
||||
Serial.println(kv.value);
|
||||
}
|
||||
```
|
||||
|
||||
The code above would print:
|
||||
|
||||
```
|
||||
first
|
||||
hello
|
||||
second
|
||||
world
|
||||
```
|
||||
|
||||
|
||||
### JsonObject::createNestedArray()
|
||||
|
||||
##### Description
|
||||
Creates a `JsonArray` as a child of the current object.
|
||||
|
||||
##### Signature
|
||||
##### Signatures
|
||||
|
||||
```c++
|
||||
JsonArray& createNestedArray(const char* key) const;
|
||||
|
Reference in New Issue
Block a user