ArduinoJson 6.9.0: the stable release
05 March 2019
ArduinoJson 6.9.0 was released a week ago; this version is an important milestone because it marks the end of the “beta” cycle for version 6. In this article, we’ll only see the last changes, if you want to see all the differences between ArduinoJson 5 and 6, please read the migration guide.
Unicode escape sequence
Thanks to Daniel Schulte, ArduinoJson is now able to decode Unicode escape sequence, like \u00DE
, to UTF-8.
However, the conversion isn’t perfect: it produces proper UTF-8 for code points below 0x10000. Above this limit the code points require two escapes sequence; in this case, ArduinoJson produces CESU-8, a degenerated variant of UTF-8.
Because few users need this feature, it’s disabled by default.
To enable it, you must set ARDUINOJSON_DECODE_UNICODE to 1
.
#define ARDUINOJSON_DECODE_UNICODE 1
#include <ArduinoJson.h>
copyArray()
In ArduinoJson 5, you could easily copy values between a JsonArray
and a regular array using JsonArray::copyFrom()
and JsonArray::copyTo()
.
In version 6.9, I merged the two member functions into a single free function named copyArray()
.
The first argument is the source, and the second is the destination.
Here is an example:
int values[] = {1,2,3};
StaticJsonDocument<256> doc;
copyArray(values, doc.to<JsonArray>());
serializeJson(doc, Serial); // [1,2,3]
The above program writes the following string to the serial port:
[1,2,3]
Beta status
There have been many breaking changes in this branch, but it’s over! That’s why ArduinoJson 6.9.0 has lost the “beta” suffix. This version is now the default one and will soon be proposed on all platforms (Arduino, PlatformIO, Particle…)
If you’re currently using ArduinoJson 5, your code will break. You can choose to keep version 5 if you want because I’ll continue fixing bugs in this branch.
If you have several projects that use different versions of the library, I recommend that you download the single header (ArduinoJson-x.x.x.h
) for each project.
New edition of the book
I published a new edition of Mastering ArduinoJson, entirely updated for ArduinoJson 6.
In addition to the changes in the syntax, I had to update two obsolete examples. Yahoo! discontinued the API that I used in the second chapter, so I replaced it with GitHub’s API. The same thing happened with Weather Underground, so I substituted it with an example that uses Reddit.
Conclusion
This is the achievement of many hours of hard work; I sincerely hope you’ll enjoy the new library and the new book.