ArduinoJson v6.18.0 Release Notes
Release Date: 2021-05-05 // almost 3 years ago-
- โ Added support for custom converters (issue #687)
- โ Added support for
Printable
(issue #1444) - โ Removed support for
char
values, see below (issue #1498) - ๐
deserializeJson()
leaves\uXXXX
unchanged instead of returningNotSupported
- ๐
deserializeMsgPack()
insertsnull
instead of returningNotSupported
- โ Removed
DeserializationError::NotSupported
- โ Added
JsonVariant::is<JsonArrayConst/JsonObjectConst>()
(issue #1412) - โ Added
JsonVariant::is<JsonVariant/JsonVariantConst>()
(issue #1412) - ๐ Changed
JsonVariantConst::is<JsonArray/JsonObject>()
to returnfalse
(issue #1412) - ๐ Simplified
JsonVariant::as<T>()
to always returnT
(see below) - โก๏ธ Updated folders list in
.mbedignore
(PR #1515 by @AGlass0fMilk) - ๐ Fixed member-call-on-null-pointer in
getMember()
when array is empty serializeMsgPack(doc, buffer, size)
doesn't add null-terminator anymore (issue #1545)serializeJson(doc, buffer, size)
adds null-terminator only if there is enough room- ๐ PlatformIO: set
build.libArchive
tofalse
(PR #1550 by @askreet)
BREAKING CHANGES
๐ > #### Support for
char
removedWe cannot cast a
JsonVariant
to achar
anymore, so the following will break:char age = doc["age"]; // error: no matching function for call to 'variantAs(VariantData*&)'
Instead, you must use another integral type, such as
int8_t
:int8_t age = doc["age"]; // OK
Similarly, we cannot assign from a
char
anymore, so the following will break:char age; doc["age"] = age; // error: no matching function for call to 'VariantRef::set(const char&)'
Instead, you must use another integral type, such as
int8_t
:int8_t age; doc["age"] = age; // OK
A deprecation warning with the message "Support for
char
is deprecated, useint8_t
oruint8_t
instead" was added to allow a smooth transition.as<T>()
always returnsT
Previously,
JsonVariant::as<T>()
could return a type different fromT
. The most common example isas<char*>()
that returned aconst char*
. While this feature simplified a few use cases, it was confusing and complicated the implementation of custom converters.Starting from this version,
as<T>
doesn't try to auto-correct the return type and always returnT
, which means that you cannot write this anymore:Serial.println(doc["sensor"].as<char*>()); // error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
Instead, you must write:
๐จ > Serial.println(doc["sensor"].as<const char*>()); // OK
A deprecation warning with the message "Replace
as<char*>()
withas<const char*>()
" was added to allow a smooth transition.๐ > ####
DeserializationError::NotSupported
removed๐ > On a different topic,
DeserializationError::NotSupported
has been removed. Instead of returning this error:deserializeJson()
leaves\uXXXX
unchanged (only whenARDUINOJSON_DECODE_UNICODE
is0
) ๐ > *deserializeMsgPack()
replaces unsupported values withnull
s
Const-aware
is<T>()
Lastly, a very minor change concerns
JsonVariantConst::is<T>()
. It used to returntrue
forJsonArray
andJsonOject
, but now it returnsfalse
. Instead, you must useJsonArrayConst
andJsonObjectConst
.