From 71be75c7a88131a302142b7f03242ce393fad4dc Mon Sep 17 00:00:00 2001 From: universam1 Date: Wed, 30 Aug 2017 14:30:57 +0200 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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.