mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-09 15:44:42 +02:00
Updated FAQ (markdown)
21
FAQ.md
21
FAQ.md
@@ -29,6 +29,7 @@
|
||||
- [How to know the type of a value?](#how-to-know-the-type-of-a-value)
|
||||
- [Can I access to object member by its index, instead of its key?](#can-i-access-to-object-member-by-its-index-instead-of-its-key)
|
||||
- [How to fix error "Ambiguous overload for 'operator='"](#how-to-fix-error-ambiguous-overload-for-operator)
|
||||
- [Why JsonVariant cannot be converted to char?](#why-jsonvariant-cannot-be-converted-to-char)
|
||||
|
||||
<!-- /MarkdownTOC -->
|
||||
|
||||
@@ -826,3 +827,23 @@ ssid = network["ssid"].as<String>();
|
||||
```
|
||||
|
||||
See issue [#118](https://github.com/bblanchon/ArduinoJson/issues/118), [#146](https://github.com/bblanchon/ArduinoJson/issues/146) and [#197](https://github.com/bblanchon/ArduinoJson/issues/197).
|
||||
|
||||
### Why JsonVariant cannot be converted to char?
|
||||
|
||||
The `char` type has been intentionally disabled to avoid an ambiguity.
|
||||
|
||||
Imagine you have this input: `{'time':'8'}`; what should be the value of `root["time"]` as a `char`?
|
||||
|
||||
I see two possible answers:
|
||||
|
||||
* Either you see `char` as an integer; in that case, the result should be `8`.
|
||||
* Or you see `char` as a character; in that case, the result should be `56` (the ASCII code of character `8`)
|
||||
|
||||
Since there is not good answer to this question, the `char` type has been disabled, but `unsigned char` and `signed char` works as integers.
|
||||
|
||||
However, I highly encourage you to use `char` to store characters, and `int8_t` or `uint8_t` to store integers. If you compile with Arduino, you also have the [byte](https://www.arduino.cc/en/Reference/Byte) type.
|
||||
|
||||
See also:
|
||||
|
||||
* [API Reference: JsonVariant::as()](https://github.com/bblanchon/ArduinoJson/wiki/API%20Reference#jsonvariantas)
|
||||
* Issues [#337](https://github.com/bblanchon/ArduinoJson/issues/337) and [#370](https://github.com/bblanchon/ArduinoJson/issues/370)
|
||||
|
Reference in New Issue
Block a user