issue2166.cpp 492 B

12345678910111213141516171819202122
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2025, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. struct CCLASS {
  7. static const char mszKey[];
  8. };
  9. TEST_CASE("Issue #2166") {
  10. JsonDocument doc;
  11. doc[CCLASS::mszKey] = 12;
  12. REQUIRE(doc.as<std::string>() == "{\"test3\":12}");
  13. JsonObject obj = doc.to<JsonObject>();
  14. obj[CCLASS::mszKey] = 12;
  15. REQUIRE(doc.as<std::string>() == "{\"test3\":12}");
  16. }
  17. const char CCLASS::mszKey[] = "test3";