Skip to content

Commit

Permalink
Fixed deserializeJson() that stopped reading after {} (fixes #1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Aug 4, 2020
1 parent 96b6571 commit 35a39b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
ArduinoJson: change log
=======================

HEAD
----

* Fixed `deserializeJson()` that stopped reading after `{}` (issue #1335)

v6.16.0 (2020-08-01)
-------

Expand Down
6 changes: 6 additions & 0 deletions extras/tests/JsonDeserializer/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,10 @@ TEST_CASE("deserialize JSON object") {
REQUIRE(obj.size() == 0);
REQUIRE(doc.memoryUsage() == JSON_OBJECT_SIZE(0));
}

SECTION("Issue #1335") {
std::string json("{\"a\":{},\"b\":{}}");
deserializeJson(doc, json);
CHECK(doc.as<std::string>() == json);
}
}
6 changes: 2 additions & 4 deletions src/ArduinoJson/Json/JsonDeserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ class JsonDeserializer {
return false;

// Empty object?
if (eat('}')) {
_error = DeserializationError::Ok;
return false;
}
if (eat('}'))
return true;

// Read each key value pair
for (;;) {
Expand Down

0 comments on commit 35a39b8

Please sign in to comment.