As I announced in the previous post, I’m removing support for C++03/C++98 in ArduinoJson. Moving forward, you’ll need a C++11-capable compiler, which you probably already have.

Why drop support for C++03?

I kept compatibility with C++03 much longer than most other C++ libraries because I wanted ArduinoJson to work with old compilers. As you probably discovered, hardware manufacturers often take a very long time to upgrade the compilers bundled in their development kits (when they ever do).

It doesn’t seem like much, but keeping compatibility with C++03 was challenging because it forced me to use antiquated techniques, such as the safe-bool idiom. I was eager to move to C++11 because then I could simplify many areas of the library and trigger new optimizations.

I wondered how many ArduinoJson users were still relying on the C++03 compatibility, so in November 2022, I started a survey on GitHub. I placed a prominent banner on arduinojson.org saying I was about to remove support for C++03.

Of the estimated 200k people exposed to this banner, only 107 responded. 86% were in favor of this change, and 14% were against it. After discussing with some of them, it was clear that they voted against the change because they didn’t even know what C++11 was and were afraid that it could break their code.

The results of the survey

I concluded that out of this sample of 200k people, none were concerned about this change; otherwise, one would have raised their voice. In other words, my obsession with staying compatible with C++03 has become irrelevant, and it was time to turn the page.

Removal of ARDUINOJSON_NAMESPACE

Thanks to the inline namespace feature, I could eliminate the ARDUINOJSON_NAMESPACE macro and all the ridiculous usings and typedefs in ArduinoJson.hpp.

This change should only affect you if you define custom converter classes. If that’s your case, you must substitute ARDUINOJSON_NAMESPACE with ArduinoJson.

A positive side-effect of this change is that the Arduino IDE now shows the correct documentation for the classes and functions of ArduinoJson.

The Arduino IDE showing the documentation for deserializeJson()

Generic string support

Thanks to the decltype operator, I could finally implement generic support for string objects. ArduinoJson now treats as a string any class that supports data()/size() (like std::string and std::string_view), or c_str()/length() (like String), which means that other string classes, such as etl::string are now supported out-of-the-box.

Evolution of code size

C++11 allowed me to slightly reduce the size of the library, as you can see in the following graphs.

Conclusion

As I said, I don’t expect anyone to be affected negatively. If you cannot switch to C++11, you’ll have to stick with ArduinoJson 6.20.x. I’ll continue fixing bugs on this branch as long as I can.

I initially planned to add more features to ArduinoJson 6, but I finally decided to start working on ArduinoJson 7. Don’t get too excited, though, as it will take a long time before it gets ready for production. Remember that ArduinoJson 6 stayed in the “beta” stage for over eight months, and version 7 will likely take as much time to mature.

Stay informed!

...or subscribe to the RSS feed

Global warming stripes by Professor Ed Hawkins (University of Reading)