From 902dfd8b0856c673a0493ef6cbb4ed753f3eadc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Wed, 13 Jan 2016 21:07:40 +0100 Subject: [PATCH] Updated FAQ (markdown) --- FAQ.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/FAQ.md b/FAQ.md index d6bc808..375315e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -277,7 +277,33 @@ void sendJson(JsonVariant json) { } ``` -See issue [#195](https://github.com/bblanchon/ArduinoJson/issues/195) +But in that case, you loose some specificities of the `JsonObject` class. +In particular, you don't have the `containsKey()` method. +If you need this function, you must cast the `JsonVariant` back to a `JsonObject&`. + +For instance: + +```c++ +void myFunction(JsonVariant variant) +{ + if (variant.is()) + { + JsonArray& array = variant; + // ... + } + else if (variant.is()) + { + JsonObject& object = variant; + // ... +  } + else + { +  // ... + } +} +``` + +See issue [#195](https://github.com/bblanchon/ArduinoJson/issues/195) and [#196](https://github.com/bblanchon/ArduinoJson/issues/196) ### What are the differences between `StaticJsonBuffer` and `DynamicJsonBuffer`?