ArduinoJson 6.1.0-beta has just been released, it returns everything by value, so you don’t have to deal with references anymore.

Another small change: JsonArray::success(), JsonObject::success() and JsonVariant::success() have been replaced with JsonArray::isNull(), JsonObject::isNull() and JsonVariant::isNull().

Breaking changes

Of course, you’ll need to update existing code, but the changes are very simple.

ArduinoJson v6.0

JsonObject& obj = doc.to<JsonObject>();
JsonArray& arr = obj.createNestedArray("key");
if (!arr.success()) {
  Serial.println("Not enough memory");
  return;
}

ArduinoJson v6.1

JsonObject obj = doc.to<JsonObject>();
JsonArray arr = obj.createNestedArray("key");
if (arr.isNull()) {
  Serial.println("Not enough memory");
  return;
}

Try online

Conclusion

As usual, this revision was intensively tested, but I flagged it as “beta” because more breaking changes may come in the next revisions. Don’t worry; the changes will be simple.

Your feedback is important, please open an issue on GitHub to start a discussion.

Stay informed!

...or subscribe to the RSS feed

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