Updated FAQ (markdown)

Benoît Blanchon
2016-01-13 21:04:31 +01:00
parent da06b521e0
commit d75b04c1bc

19
FAQ.md

@@ -260,6 +260,25 @@ array[0].is<JsonObject&>(); // return false
See issues [#148](https://github.com/bblanchon/ArduinoJson/issues/148) and [#175](https://github.com/bblanchon/ArduinoJson/issues/175). See issues [#148](https://github.com/bblanchon/ArduinoJson/issues/148) and [#175](https://github.com/bblanchon/ArduinoJson/issues/175).
### How to write a function that works with both `JsonArray` and `JsonObject`?
There is no base class for `JsonArray` and `JsonObject`.
(Back in version 3.0, they used to derive from `Printable`, but this inheritance has been removed to reduce the memory footprint.)
However, both `JsonArray` and `JsonObject` can be "stored" in a `JsonVariant`. (I put "stored" in quotes because the `JsonVariant` only contains a reference, not a copy.)
So here is your function:
```c++
void sendJson(JsonVariant json) {
char buffer[512];
json.printTo(buffer, sizeof(buffer));
g_server.send(200, "application/json", buffer);
}
```
See issue [#195](https://github.com/bblanchon/ArduinoJson/issues/195)
### What are the differences between `StaticJsonBuffer` and `DynamicJsonBuffer`? ### What are the differences between `StaticJsonBuffer` and `DynamicJsonBuffer`?
| `StaticJsonBuffer` | `DynamicJsonBuffer` | `StaticJsonBuffer` | `DynamicJsonBuffer`