Updated API Reference (markdown)

Benoît Blanchon
2016-08-30 10:17:34 +02:00
parent 6418605bd9
commit e28912a438

@@ -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() ### JsonObject::createNestedArray()
##### Description ##### Description
Creates a `JsonArray` as a child of the current object. Creates a `JsonArray` as a child of the current object.
##### Signature ##### Signatures
```c++ ```c++
JsonArray& createNestedArray(const char* key) const; JsonArray& createNestedArray(const char* key) const;
@@ -782,8 +829,8 @@ will print
{ {
"status": "on", "status": "on",
"levels": [ "levels": [
10, 10,
20 20
] ]
} }
``` ```
@@ -834,8 +881,8 @@ will print
{ {
"city": "Paris", "city": "Paris",
"weather": { "weather": {
"temp": 14.20, "temp": 14.20,
"cond": "cloudy" "cond": "cloudy"
} }
} }
``` ```