Skip to content

is<T>() returns wrong value, only with bool #214

Closed
@marvinroger

Description

@marvinroger

I am using an ESP8266 (NodeMCU 1.0) with the following sketch:

#include <ArduinoJson.h>

const 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);
}

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 with bool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv5ArduinoJson 5

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions