Skip to content

ArduinoJson 6.0.0-beta

Pre-release
Pre-release
Compare
Choose a tag to compare
@bblanchon bblanchon released this 07 Jun 09:20

Summary

This release is the first of a new major revision of the library.
It adds new features, like:

  1. MessagePack serialization and deserialization,
  2. Error code to tell why deserialization failed,
  3. Support for non zero terminated input.

Unfortunately, it requires changing the existing programs; please see the "breaking changes" section below.

More information on arduinojson.org

Changes since 5.13.2

  • Added DynamicJsonDocument and StaticJsonDocument
  • Added deserializeJson()
  • Added serializeJson() and serializeJsonPretty()
  • Added measureJson() and measureJsonPretty()
  • Added serializeMsgPack(), deserializeMsgPack() and measureMsgPack() (issue #358)
  • Added example MsgPackParser.ino (issue #358)
  • Added support for non zero-terminated strings (issue #704)
  • Removed JsonBuffer::parseArray(), parseObject() and parse()
  • Removed JsonBuffer::createArray() and createObject()
  • Removed printTo() and prettyPrintTo()
  • Removed measureLength() and measurePrettyLength()
  • Removed all deprecated features

BREAKING CHANGES ⚠️

Deserialization

Old code:

DynamicJsonBuffer jb;
JsonObject& obj = jb.parseObject(json);
if (obj.success()) {

}

New code:

DynamicJsonDocument doc;
DeserializationError error = deserializeJson(doc, json);
if (error) {

}
JsonObject& obj = doc.as<JsonObject>();

Serialization

Old code:

DynamicJsonBuffer jb;
JsonObject& obj = jb.createObject();
obj["key"] = "value";
obj.printTo(Serial);

New code:

DynamicJsonDocument obj;
JsonObject& obj = doc.to<JsonObject>();
obj["key"] = "value";
serializeJson(doc, Serial);

View version history

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.0.0-beta.h put it in your project folder
  3. Download ArduinoJson-v6.0.0-beta.zip and extract it in you libraries folder

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

Try online