diff --git a/CHANGELOG.md b/CHANGELOG.md index f6eb155b..a2e97771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,13 @@ HEAD * `JsonDocument` was missing in the ArduinoJson namespace * Added `memoryUsage()` to `JsonArray`, `JsonObject`, and `JsonVariant` * Added `nesting()` to `JsonArray`, `JsonDocument`, `JsonObject`, and `JsonVariant` +* Replaced `JsonDocument::nestingLimit` with an additional parameter + to `deserializeJson()` and `deserializeMsgPack()` > ### BREAKING CHANGES > +> #### `DynamicJsonDocument`'s constructor +> > The parameter to the constructor of `DynamicJsonDocument` is now mandatory > > Old code: @@ -28,6 +32,23 @@ HEAD > ```c++ > DynamicJsonDocument doc(1024); > ``` +> +> #### Nesting limit +> +> `JsonDocument::nestingLimit` was replaced with a new parameter to `deserializeJson()` and `deserializeMsgPack()`. +> +> Old code: +> +> ```c++ +> doc.nestingLimit = 15; +> deserializeJson(doc, input); +> ``` +> +> New code: +> +> ```c++ +> deserializeJson(doc, input, DeserializationOption::NestingLimit(15)); +> ``` v6.7.0-beta (2018-12-07) ----------- diff --git a/src/ArduinoJson.hpp b/src/ArduinoJson.hpp index 02223b27..a0a6ffee 100644 --- a/src/ArduinoJson.hpp +++ b/src/ArduinoJson.hpp @@ -49,4 +49,8 @@ using ARDUINOJSON_NAMESPACE::serializeJson; using ARDUINOJSON_NAMESPACE::serializeJsonPretty; using ARDUINOJSON_NAMESPACE::serializeMsgPack; using ARDUINOJSON_NAMESPACE::StaticJsonDocument; + +namespace DeserializationOption { +using ARDUINOJSON_NAMESPACE::NestingLimit; +} } // namespace ArduinoJson diff --git a/src/ArduinoJson/Deserialization/NestingLimit.hpp b/src/ArduinoJson/Deserialization/NestingLimit.hpp new file mode 100644 index 00000000..64e57173 --- /dev/null +++ b/src/ArduinoJson/Deserialization/NestingLimit.hpp @@ -0,0 +1,17 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#include "../Configuration.hpp" + +namespace ARDUINOJSON_NAMESPACE { + +struct NestingLimit { + NestingLimit() : value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} + explicit NestingLimit(uint8_t n) : value(n) {} + + uint8_t value; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/src/ArduinoJson/Deserialization/deserialize.hpp b/src/ArduinoJson/Deserialization/deserialize.hpp index d2d5bdbd..c3a4fa69 100644 --- a/src/ArduinoJson/Deserialization/deserialize.hpp +++ b/src/ArduinoJson/Deserialization/deserialize.hpp @@ -5,12 +5,13 @@ #pragma once #include "../StringStorage/StringStorage.hpp" -#include "./ArduinoStreamReader.hpp" -#include "./CharPointerReader.hpp" -#include "./DeserializationError.hpp" -#include "./FlashStringReader.hpp" -#include "./IteratorReader.hpp" -#include "./StdStreamReader.hpp" +#include "ArduinoStreamReader.hpp" +#include "CharPointerReader.hpp" +#include "DeserializationError.hpp" +#include "FlashStringReader.hpp" +#include "IteratorReader.hpp" +#include "NestingLimit.hpp" +#include "StdStreamReader.hpp" namespace ARDUINOJSON_NAMESPACE { @@ -26,22 +27,24 @@ TDeserializer makeDeserializer(MemoryPool &pool, // TString = const std::string&, const String& template