8000 Fixed `JsonVariant::is<String>()` (closes #763) · java64/ArduinoJson@0b3af16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b3af16

Browse files
committed
Fixed JsonVariant::is<String>() (closes bblanchon#763)
1 parent fa1a40a commit 0b3af16

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ HEAD
66

77
* Improved float serialization when `-fsingle-precision-constant` is used
88
* Fixed `JsonVariant::is<int>()` that returned true for empty strings
9+
* Fixed `JsonVariant::is<String>()` (closes #763)
910

1011
v5.13.2
1112
-------

src/ArduinoJson/JsonVariant.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,11 @@ class JsonVariant : public Internals::JsonVariantBase<JsonVariant> {
274274
//
275275
// bool is<const char*>() const;
276276
// bool is<char*>() const;
277+
// bool is<std::string>() const;
277278
template <typename T>
278279
typename Internals::EnableIf<Internals::IsSame<T, const char *>::value ||
279-
Internals::IsSame<T, char *>::value,
280+
Internals::IsSame<T, char *>::value ||
281+
Internals::StringTraits<T>::has_append,
280282
bool>::type
281283
is() const {
282284
return variantIsString();
@@ -352,4 +354,4 @@ DEPRECATED("Decimal places are ignored, use the double value instead")
352354
inline JsonVariant double_with_n_digits(double value, uint8_t) {
353355
return JsonVariant(value);
354356
}
355-
}
357+
} // namespace ArduinoJson

test/JsonVariant/is.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void checkIsInteger(JsonVariant var) {
5858

5959
void checkIsString(JsonVariant var) {
6060
REQUIRE(var.is<const char*>());
61+
REQUIRE(var.is<std::string>());
6162

6263
REQUIRE_FALSE(var.is<bool>());
6364
REQUIRE_FALSE(var.is<int>());

0 commit comments

Comments
 (0)
0