Updated FAQ (markdown)

Benoît Blanchon
2015-11-02 18:13:12 +01:00
parent 818fd42ae9
commit eff2fabeaa

29
FAQ.md

@@ -136,4 +136,31 @@ void serialize(const SensorData& data, char* json, size_t maxSize)
As you can see the `StaticJsonBuffer` is kept in memory as short as possible, so that the remain of your program is unaffected by the JSON serialization.
Also you can see that neither `JsonArray` nor `JsonObject` leak out of the serialization code. This maintain a good isolation and reduce the coupling with the library.
Also you can see that neither `JsonArray` nor `JsonObject` leak out of the serialization code. This maintain a good isolation and reduce the coupling with the library.
# How to fix error "Ambiguous overload for 'operator='"
There is a case where you need the compiler: it's when you convert a `JsonVariant` to a `String`.
For example:
```c++
String ssid = network["ssid"];
ssid = network["ssid"];
```
The first line will compile but the second will fail with the following error:
```
error: ambiguous overload for 'operator=' (operand types are 'String' and 'ArduinoJson::JsonObjectSubscript<const char*>')
```
The solution is to remove the ambiguity with any of the following replacement:
```c++
ssid = (String)network["ssid"];
ssid = (const char*)network["ssid"];
ssid = network["ssid"].asString();
ssid = network["ssid"].as<const char*>();
ssid = network["ssid"].as<String>();
```