diff --git a/JsonGenerator/JsonValue.h b/JsonGenerator/JsonValue.h index ea7fa898..12b491df 100644 --- a/JsonGenerator/JsonValue.h +++ b/JsonGenerator/JsonValue.h @@ -59,6 +59,11 @@ namespace ArduinoJson content.asDouble = value; } + operator bool() + { + return content.asBool; + } + operator const char*() { return ""; diff --git a/JsonGeneratorTests/JsonValue_Cast_Tests.cpp b/JsonGeneratorTests/JsonValue_Cast_Tests.cpp index 72b5dcf1..3bbd73a7 100644 --- a/JsonGeneratorTests/JsonValue_Cast_Tests.cpp +++ b/JsonGeneratorTests/JsonValue_Cast_Tests.cpp @@ -34,6 +34,12 @@ namespace JsonGeneratorTests setValueAndCheckCast(42L); } + TEST_METHOD(Bool) + { + setValueAndCheckCast(true); + setValueAndCheckCast(false); + } + private: template