mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Fixed JsonVariant::is<String>() (closes #763)
				
					
				
			This commit is contained in:
		| @@ -6,6 +6,7 @@ HEAD | ||||
|  | ||||
| * Improved float serialization when `-fsingle-precision-constant` is used | ||||
| * Fixed `JsonVariant::is<int>()` that returned true for empty strings | ||||
| * Fixed `JsonVariant::is<String>()` (closes #763) | ||||
|  | ||||
| v5.13.2 | ||||
| ------- | ||||
|   | ||||
| @@ -274,9 +274,11 @@ class JsonVariant : public Internals::JsonVariantBase<JsonVariant> { | ||||
|   // | ||||
|   // bool is<const char*>() const; | ||||
|   // bool is<char*>() const; | ||||
|   // bool is<std::string>() const; | ||||
|   template <typename T> | ||||
|   typename Internals::EnableIf<Internals::IsSame<T, const char *>::value || | ||||
|                                    Internals::IsSame<T, char *>::value, | ||||
|                                    Internals::IsSame<T, char *>::value || | ||||
|                                    Internals::StringTraits<T>::has_append, | ||||
|                                bool>::type | ||||
|   is() const { | ||||
|     return variantIsString(); | ||||
| @@ -352,4 +354,4 @@ DEPRECATED("Decimal places are ignored, use the double value instead") | ||||
| inline JsonVariant double_with_n_digits(double value, uint8_t) { | ||||
|   return JsonVariant(value); | ||||
| } | ||||
| } | ||||
| }  // namespace ArduinoJson | ||||
|   | ||||
| @@ -58,6 +58,7 @@ void checkIsInteger(JsonVariant var) { | ||||
|  | ||||
| void checkIsString(JsonVariant var) { | ||||
|   REQUIRE(var.is<const char*>()); | ||||
|   REQUIRE(var.is<std::string>()); | ||||
|  | ||||
|   REQUIRE_FALSE(var.is<bool>()); | ||||
|   REQUIRE_FALSE(var.is<int>()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user