Updated Examples (markdown)

universam1
2017-08-30 14:30:57 +02:00
parent 54f3dce7c9
commit 71be75c7a8

@@ -71,6 +71,8 @@ getting the data on JSON format and parsing the buffer:
## Example 3: iterators
### JsonArray
```c++
char json[] = "[\"A\",\"B\",\"C\"]";
JsonArray& array = jsonBuffer.parseArray(json);
@@ -85,6 +87,7 @@ for(JsonArray::iterator it=array.begin(); it!=array.end(); ++it)
}
```
### JsonObject
```c++
char json[] = "{\"key\":\"value\"}";
@@ -104,6 +107,22 @@ for(JsonObject::iterator it=object.begin(); it!=object.end(); ++it)
}
```
### JsonVariant
for an object:
```c++
for( const auto& kv : variant.as<JsonObject>() ) {
Serial.println(kv.key);
Serial.println(kv.value.as<char*>());
}
```
and for an array:
```c++
for( const auto& value : variant.as<JsonArray>() ) {
Serial.println(value.as<char*>());
}
```
## Example 4: Serialize and Deserialize
Here is the canonical example for serializing and deserializing with ArduinoJson.
By following this example, you are making the best usage of your memory and you maintain a good software design.