diff --git a/Examples.md b/Examples.md index c27461a..aa8ec2e 100644 --- a/Examples.md +++ b/Examples.md @@ -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() ) { + Serial.println(kv.key); + Serial.println(kv.value.as()); +} +``` +and for an array: +```c++ +for( const auto& value : variant.as() ) { + Serial.println(value.as()); +} +``` + ## 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.