ArduinoJson v6.15.0 Release Notes
Release Date: 2020-03-22 // about 4 years ago-
๐ฑ ๐ฐ Read the complete article on arduinojson.org
๐ Changes since 6.14.1
- โ Added
DeserializationOption::Filter
(issue #959) - โ Added example
JsonFilterExample.ino
- ๐ Changed the array subscript operator to automatically add missing elements
- ๐ Fixed "deprecated-copy" warning on GCC 9 (fixes #1184)
- ๐ Fixed
MemberProxy::set(char[])
not duplicating the string (issue #1191) - ๐ Fixed enums serialized as booleans (issue #1197)
- ๐ Fixed incorrect string comparison on some platforms (issue #1198)
- โ Added move-constructor and move-assignment to
BasicJsonDocument
- โ Added
BasicJsonDocument::garbageCollect()
(issue #1195) - โ Added
StaticJsonDocument::garbageCollect()
- ๐ Changed copy-constructor of
BasicJsonDocument
to preserve the capacity of the source. - โ Removed copy-constructor of
JsonDocument
(issue #1189)
๐ฅ BREAKING CHANGES โ ๏ธ
Copy-constructor of
BasicJsonDocument
In previous versions, the copy constructor of
BasicJsonDocument
looked at the source'smemoryUsage()
to choose its capacity.
Now, the copy constructor ofBasicJsonDocument
uses the same capacity as the source.
Example:DynamicJsonDocument doc1(64); doc1.set(String("example")); DynamicJsonDocument doc2 = doc1; Serial.print(doc2.capacity()); // 8 with ArduinoJson 6.14// 64 with ArduinoJson 6.15
๐ I made this change to get consistent results between copy-constructor and move-constructor, and whether RVO applies or not.
โก๏ธ If you use the copy-constructor to optimize your documents, you can usegarbageCollect()
orshrinkToFit()
instead.Copy-constructor of
JsonDocument
In previous versions, it was possible to create a function that take a
JsonDocument
by value.void myFunction(JsonDocument doc) {}
This function gives the wrong clues because it doesn't receive a copy of the
JsonDocument
, only a sliced version.
It worked because the copy constructor copied the internal pointers, but it was an accident.
From now, if you need to pass aJsonDocument
to a function, you must use a reference:void myFunction(JsonDocument& doc) {}
How to install
There are several ways to install ArduinoJson, from simpler to more complex:
- Use the Arduino Library Manager
- Download
ArduinoJson-v6.15.0.h
put it in your project folder - Download
ArduinoJson-v6.15.0.zip
and extract it in youlibraries
folder
Note:
ArduinoJson-v6.15.0.h
andArduinoJson-v6.15.0.hpp
are almost identical; the difference is that the.hpp
keeps everything in theArduinoJson
namespace.Try online
- โ Added