mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-14 01:54:48 +02:00
Updated FAQ (markdown)
29
FAQ.md
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>();
|
||||
```
|
Reference in New Issue
Block a user