ArduinoJson v6.15.0 Release Notes

Release Date: 2020-03-22 // about 1 year 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)

    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