-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is<T>()
returns wrong value, only with bool
#214
Comments
The bug is real, but the code sample is wrong. Here is the fixed code: #include <ArduinoJson.h>
char json[] = "{\"ota\": {\"enabled\": true}}";
void setup() {
Serial.begin(115200);
Serial.println();
StaticJsonBuffer<JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(1)> jsonBuffer;
JsonObject& parsedJson = jsonBuffer.parseObject(json);
if (parsedJson["ota"]["enabled"].is<bool>()) {
Serial.println("ota.enabled is a bool");
} else {
Serial.println("ota.enabled is not a bool");
}
}
void loop() {
delay(1000);
} |
Right, my C++ background is a bit limited! But in my code I'm actually using mutable strings. |
I fixed the bug, I just need to merge and make a new release |
Great, thanks for the quick fix. |
Fix in version 5.0.8 |
I am using an ESP8266 (NodeMCU 1.0) with the following sketch:
This prints
ota.enabled is not a bool
, but it obviously is.Note I tested with
const char*
,unsigned long
,JsonObject&
and it works well, the problem only appears withbool
.The text was updated successfully, but these errors were encountered: