ArduinoJson 6.3.0-beta * Implemented reference semantics for `JsonVariant` * Replace `JsonPair`'s `key` and `value` with `key()` and `value()` * Fixed `serializeJson(obj[key], dst)` (issue #794)
Special note ⚠ ️
ArduinoJson 6 requires updating code written for version 5. See the migration guide for details.
Changes since 6.2.3-beta
- Implemented reference semantics for
JsonVariant - Replace
JsonPair'skeyandvaluewithkey()andvalue() - Fixed
serializeJson(obj[key], dst)(issue #794)
BREAKING CHANGES ⚠ ️
JsonVariant
JsonVariant now has a semantic similar to JsonObject and JsonArray.
It's a reference to a value stored in the JsonDocument.
As a consequence, a JsonVariant cannot be used as a standalone variable anymore.
Old code:
JsonVariant myValue = 42;
New code:
DynamicJsonDocument doc;
JsonVariant myValue = doc.to<JsonVariant>();
myValue.set(42);
JsonPair
Old code:
for(JsonPair p : myObject) {
Serial.println(p.key);
Serial.println(p.value.as<int>());
}
New code:
for(JsonPair p : myObject) {
Serial.println(p.key());
Serial.println(p.value().as<int>());
}
CAUTION: the key is now read only!
How to install
There are several ways to install ArduinoJson, from simpler to more complex:
- Use the Arduino Library Manager
- Download
ArduinoJson-v6.3.0-beta.hput it in your project folder - Download
ArduinoJson-v6.3.0-beta.zipand extract it in youlibrariesfolder
Note: ArduinoJson-v6.3.0-beta.h are ArduinoJson-v6.3.0-beta.hpp are almost identical; the difference is that the .hpp keeps everything in the ArduinoJson namespace.