ArduinoJson 6.15.0
* 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)

📰 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)

View version history

BREAKING CHANGES

Copy-constructor of BasicJsonDocument

In previous versions, the copy constructor of BasicJsonDocument looked at the source's memoryUsage() to choose its capacity. Now, the copy constructor of BasicJsonDocument 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 use garbageCollect() or shrinkToFit() 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 a JsonDocument 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:

  1. Use the Arduino Library Manager
  2. Download ArduinoJson-v6.15.0.h put it in your project folder
  3. Download ArduinoJson-v6.15.0.zip and extract it in you libraries folder

Note: ArduinoJson-v6.15.0.h and ArduinoJson-v6.15.0.hpp are almost identical; the difference is that the .hpp keeps everything in the ArduinoJson namespace.

Try online