Sfoglia il codice sorgente

deserializeJson() leaves \uXXXX instead of returning NotSupported

Benoit Blanchon 5 anni fa
parent
commit
cc7ebfd11e

+ 1 - 0
CHANGELOG.md

@@ -5,6 +5,7 @@ HEAD
 ----
 
 * Removed support for `char` values, see below (issue #1498)
+* `deserializeJson()` leaves `\uXXXX` unchanged instead of returning `NotSupported`
 
 > ### BREAKING CHANGES
 >

+ 2 - 1
extras/tests/MixedConfiguration/decode_unicode_0.cpp

@@ -7,5 +7,6 @@ TEST_CASE("ARDUINOJSON_DECODE_UNICODE == 0") {
   DynamicJsonDocument doc(2048);
   DeserializationError err = deserializeJson(doc, "\"\\uD834\\uDD1E\"");
 
-  REQUIRE(err == DeserializationError::NotSupported);
+  REQUIRE(err == DeserializationError::Ok);
+  REQUIRE(doc.as<std::string>() == "\\uD834\\uDD1E");
 }

+ 2 - 3
src/ArduinoJson/Json/JsonDeserializer.hpp

@@ -384,11 +384,10 @@ class JsonDeserializer {
             return false;
           if (codepoint.append(codeunit))
             Utf8::encodeCodepoint(codepoint.value(), _stringStorage);
-          continue;
 #else
-          _error = DeserializationError::NotSupported;
-          return false;
+          _stringStorage.append('\\');
 #endif
+          continue;
         }
 
         // replace char