JsonObject::createNestedObject() returns JsonObject::invalid() if key is null (issue #1891)JsonObject::createNestedArray() returns JsonArray::invalid() if key is nullStaticJsonDocument, DynamicJsonDocument...-fsingle-precision-constant is usedJsonVariant::is<int>() that returned true for empty stringsJsonVariant::is<String>() (closes #763)JsonBuffer::parse() not respecting nesting limit correctly (issue #693)strcmp() (PR #745 from Mike Karlesky)ARDUINOJSON_VERSION, ARDUINOJSON_VERSION_MAJOR...JsonVariant::operator|(int) that returned the default value if the variant contained a double (issue #675)RawJson() accepts any kind of string and obeys to the same rules for duplicationstrdup() to const char* to prevent double duplicationstrdup() as deprecatedNew rules for string duplication
type duplication const char* no char* noyesString yes std::string yes const __FlashStringHelper* yes These new rules make
JsonBuffer::strdup()useless.
JsonVariant::operator| to return a default value (see below)How to use the new feature?
If you have a block like this:
const char* ssid = root["ssid"]; if (!ssid) ssid = "default ssid";You can simplify like that:
const char* ssid = root["ssid"] | "default ssid";
DynamicJsonBuffer::clear() not resetting allocation size (issue #561)PGM_P as Particle 0.6.2 doesn't define it (issue #546)ARDUINOJSON_DOUBLE_IS_64BITS as it became useless.JsonBuffer non-copyable (PR #524 by @luisrayas3)StaticJsonBuffer::clear()DynamicJsonBuffer::clear()ARDUINOJSON_DOUBLE_IS_64BITSARDUINOJSON_EMBEDDED_MODE1e7 and 1e-5 (issues #288, #427 and #506)JsonVariant::is<double>() now returns true for integersIsBaseOf is not a member of ArduinoJson::TypeTraits (issue #495)forming reference to reference (issue #495)BREAKING CHANGES :warning:
Old syntax New syntax double_with_n_digits(3.14, 2)3.14float_with_n_digits(3.14, 2)3.14fobj.set("key", 3.14, 2)obj["key"] = 3.14arr.add(3.14, 2)arr.add(3.14)
Input Old output New output 3.141593.143.1415942.042.00420.00.000
Expression Old result New result JsonVariant(42).is<int>()truetrueJsonVariant(42).is<float>()falsetrueJsonVariant(42).is<double>()falsetrue
JsonArray::remove(iterator) (issue #479)JsonObject::remove(iterator)JsonArray::removeAt(size_t) into remove(size_t)include/ to src/floating constant exceeds range of floatand floating constant truncated to zero (issue #483)Print class and converted printTo() to a template method (issue #276)IndentedPrintExample.inostrtod() (issue #453)strtol() (issue #465)char is now treated as an integral type (issue #337, #370)DynamicJsonBuffer when memory allocation fails (issue #433)== and != for two JsonVariants (issue #436)JsonVariant::operator[const FlashStringHelper*] (issue #441)Stream timeout (issue #422)JsonObject is a char[] (issue #423)const referencesunsigned char* (issue #428)deprecated attribute on asArray(), asObject() and asString() (issue #420)volatile int to a JsonVariant (issue #415)ARDUINOJSON_ENABLE_STD_STREAM and ARDUINOJSON_ENABLE_ARDUINO_STREAM are set to 1== to compare JsonVariant and strings (issue #402)Stream (issue #300)BREAKING CHANGES :warning:
JsonBuffer::parseObject()andJsonBuffer::parseArray()have been pulled down to the derived classesDynamicJsonBufferandStaticJsonBufferBase.This means that if you have code like:
void myFunction(JsonBuffer& jsonBuffer);you need to replace it with one of the following:
void myFunction(DynamicJsonBuffer& jsonBuffer); void myFunction(StaticJsonBufferBase& jsonBuffer); template<typename TJsonBuffer> void myFunction(TJsonBuffer& jsonBuffer);
printTo(char[N]) and prettyPrintTo(char[N]) (issue #292)root["A"]["B"] = "C" (issue #352)*.ipp to *Impl.hpp because they were ignored by Arduino IDE (issue #396)String or std::stringArduinoJson::StringJsonVariant::defaultValue<T>()JsonObject::get() and JsonArray.get()StringSumHelper (issue #184)ARDUINOJSON_USE_ARDUINO_STRING by ARDUINOJSON_ENABLE_STD_STRING and ARDUINOJSON_ENABLE_ARDUINO_STRING (issue #378)StringExample.ino to show where String can be usedBREAKING CHANGES :warning:
The non-template functions
JsonObject::get()andJsonArray.get()have been removed. This means that you need to explicitely tell the type you expect in return.Old code:
#define ARDUINOJSON_USE_ARDUINO_STRING 0 JsonVariant value1 = myObject.get("myKey"); JsonVariant value2 = myArray.get(0);New code:
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 #define ARDUINOJSON_ENABLE_STD_STRING 1 JsonVariant value1 = myObject.get<JsonVariant>("myKey"); JsonVariant value2 = myArray.get<JsonVariant>(0);
array[idx].as<JsonVariant>() and object[key].as<JsonVariant>()JsonObject::set() (issue #350)Prettyfier and Print (issue #354)+ (issue #349)-Wparentheses warning introduced in v5.6.5 (PR #335 by @nuket).mbedignore for ARM mbdeb (PR #334 by @nuket)JsonVariant::success() which didn't propagate JsonArray::success() nor JsonObject::success() (issue #342).as<char*>() now returns true when input is null (issue #330)as<JsonArray>() as a synonym for as<JsonArray&>()... (issue #291)call of overloaded isinf(double&) is ambiguous (issue #284)#undef isnan (issue #284)#pragma once (issue #310)JsonVariant::success() (issue #279)JsonVariant::invalid<T>() to JsonVariant::defaultValue<T>()::String to ArduinoJson::String (issue #275)::Print to ArduinoJson::Print tooftoa (issues #266, #267, #269 and #270)JsonVariant JsonBuffer::parse() (issue #265)unsigned long printed as signed long (issue #170)JsonVariant::as<char*>() as a synonym for JsonVariant::as<const char*>() (issue #257)JsonHttpClient (issue #256)JsonArray::copyTo() and JsonArray::copyFrom() (issue #254)RawJson() to insert pregenerated JSON portions (issue #259)long long (issue #171)ArduinoJson/Configuration.hppBREAKING CHANGE :warning:
If you defined
ARDUINOJSON_ENABLE_STD_STREAM, you now need to define it to1.
JsonVariant::is<bool>() that was incorrectly returning false (issue #214)add_subdirectory(ArduinoJson/src)String to be a typedef of std::string (issues #142 and #161)BREAKING CHANGES :warning:
JsonVariant(true).as<String>()now returns"true"instead of"1"JsonVariant(false).as<String>()now returns"false"instead of"0"
DynamicJsonBuffer constructor to set initial size (issue #152)JsonObjectSuscript::set(value, decimals) (issue #143)float instead of double to reduce the size of JsonVariant (issue #134)JsonArraySubscript and JsonObjectSubscript (issue #122)printTo(String) which wrote numbers instead of strings (issue #120)JsonArray::is<T>() and some others (issue #121)parseObject(String) and parseArray(String), when the
StaticJsonBuffer is too small to hold a copy of the stringString class (issues #55, #56, #70, #77)JsonBuffer::strdup() to make a copy of a string (issues #10, #57)strdup() for String but not for char* (issues #84, #87)JsonVariant to leverage converting constructors instead of assignment operators (issue #66)BREAKING CHANGES :warning:
JsonObject::add()was renamed toset()JsonArray::at()andJsonObject::at()were renamed toget()- Number of digits of floating point value are now set with
double_with_n_digits()
Personal note about the String class:
Support of the String class has been added to the library because many people use it in their programs.
However, you should not see this as an invitation to use the String class.
The String class is bad because it uses dynamic memory allocation.
Compared to static allocation, it compiles to a bigger, slower program, and is less predictable.
You certainly don't want that in an embedded environment!
DynamicJsonBuffer when memory allocation fails (issue #92)Upgrading is recommended since previous versions contain a potential security risk.
Special thanks to Giancarlo Canales Barreto for finding this nasty bug.
JsonArray::measureLength() and JsonObject::measureLength() (issue #75)JsonArray::removeAt() to remove an element of an array (issue #58)DynamicJsonBuffer when parsing huge JSON files (issue #65)parseArray() and parseObject() when allocation fails (issue #68)BREAKING CHANGES :warning:
API changed significantly since v3, see Migrating code to the new API.