Parcourir la source

Merge branch 'master' into 6.x

Benoit Blanchon il y a 7 ans
Parent
commit
b11ad4077b
5 fichiers modifiés avec 20 ajouts et 5 suppressions
  1. 10 2
      .travis.yml
  2. 2 0
      CHANGELOG.md
  3. 1 1
      appveyor.yml
  4. 6 2
      src/ArduinoJson/JsonVariant.hpp
  5. 1 0
      test/JsonVariant/is.cpp

+ 10 - 2
.travis.yml

@@ -97,11 +97,19 @@ matrix:
     - compiler: gcc
       env: SCRIPT=coverage
     - os: osx
-      osx_image: xcode6.4
+      osx_image: xcode7.3
       compiler: clang
       env: SCRIPT=cmake
     - os: osx
-      osx_image: xcode7.3
+      osx_image: xcode8.3
+      compiler: clang
+      env: SCRIPT=cmake
+    - os: osx
+      osx_image: xcode9.4
+      compiler: clang
+      env: SCRIPT=cmake
+    - os: osx
+      osx_image: xcode10
       compiler: clang
       env: SCRIPT=cmake SANITIZE=address
     - env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno

+ 2 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@ HEAD
 * Fixed object keys not being duplicated
 * `JsonPair::key()` now returns a `JsonKey`
 * Increased the default capacity of `DynamicJsonDocument`
+* Fixed `JsonVariant::is<String>()` (closes #763)
 
 v6.4.0-beta (2018-09-11)
 -----------
@@ -87,6 +88,7 @@ v6.2.0-beta (2018-07-12)
 -----------
 
 * Disabled lazy number deserialization (issue #772)
+* Fixed `JsonVariant::is<int>()` that returned true for empty strings
 * Improved float serialization when `-fsingle-precision-constant` is used
 * Renamed function `RawJson()` to `serialized()`
 * `serializeMsgPack()` now supports values marked with `serialized()`

+ 1 - 1
appveyor.yml

@@ -1,4 +1,4 @@
-version: 6.0.1.{build}
+version: 6.4.0.{build}
 environment:
   matrix:
   - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017

+ 6 - 2
src/ArduinoJson/JsonVariant.hpp

@@ -305,9 +305,13 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
   //
   // bool is<const char*>() const;
   // bool is<char*>() const;
+  // bool is<std::string>() const;
+  // bool is<String>() const;
   template <typename T>
-  FORCE_INLINE typename enable_if<
-      is_same<T, const char *>::value || is_same<T, char *>::value, bool>::type
+  FORCE_INLINE typename enable_if<is_same<T, const char *>::value ||
+                                      is_same<T, char *>::value ||
+                                      IsWriteableString<T>::value,
+                                  bool>::type
   is() const {
     return _data && (_data->type == JSON_LINKED_STRING ||
                      _data->type == JSON_OWNED_STRING);

+ 1 - 0
test/JsonVariant/is.cpp

@@ -79,6 +79,7 @@ void checkIsString(const char *value) {
   var.set(value);
 
   REQUIRE(var.is<const char *>());
+  REQUIRE(var.is<std::string>());
 
   REQUIRE_FALSE(var.is<bool>());
   REQUIRE_FALSE(var.is<int>());