diff --git a/FAQ.md b/FAQ.md index 54bd316..50478dc 100644 --- a/FAQ.md +++ b/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. \ No newline at end of file +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') +``` + +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(); +ssid = network["ssid"].as(); +``` \ No newline at end of file