From 6e4f1dc7569ad5809adb3904b0205be77e744d86 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 17 Jul 2018 10:24:21 +0200 Subject: [PATCH] Fixed `JsonObject` not inserting keys of type `String` (fixes #782) --- CHANGELOG.md | 5 +++++ src/ArduinoJson/Strings/ArduinoString.hpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f965687..3a5221e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ArduinoJson: change log ======================= +HEAD +---- + +* Fixed `JsonObject` not inserting keys of type `String` (issue #782) + v6.2.0-beta ----------- diff --git a/src/ArduinoJson/Strings/ArduinoString.hpp b/src/ArduinoJson/Strings/ArduinoString.hpp index 0c23e4b0..723ac204 100644 --- a/src/ArduinoJson/Strings/ArduinoString.hpp +++ b/src/ArduinoJson/Strings/ArduinoString.hpp @@ -15,7 +15,7 @@ class ArduinoString { template const char* save(Buffer* buffer) const { - if (!_str->c_str()) return NULL; // <- Arduino string can return NULL + if (is_null()) return NULL; size_t n = _str->length() + 1; void* dup = buffer->alloc(n); if (dup != NULL) memcpy(dup, _str->c_str(), n); @@ -24,7 +24,7 @@ class ArduinoString { bool is_null() const { // Arduino's String::c_str() can return NULL - return _str->c_str(); + return !_str->c_str(); } bool equals(const char* expected) const {