This commit is contained in:
Benoit Blanchon
2023-08-19 16:08:12 +02:00
parent 7bd2ea1072
commit 750d53f8c7
38 changed files with 207 additions and 206 deletions

View File

@ -14,7 +14,7 @@ Before opening a bug report, please use the ArduinoJson Troubleshooter as it may
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**Troubleshooter report** **Troubleshooter report**
Here is the report generated by the [ArduinoJson Troubleshooter](https://arduinojson.org/v6/troubleshooter/): Here is the report generated by the [ArduinoJson Troubleshooter](https://arduinojson.org/v7/troubleshooter/):
[Paste the report here] [Paste the report here]
**Environment** **Environment**

View File

@ -1,8 +1,8 @@
blank_issues_enabled: true blank_issues_enabled: true
contact_links: contact_links:
- name: 👨‍🏫 ArduinoJson Assistant - name: 👨‍🏫 ArduinoJson Assistant
url: https://arduinojson.org/v6/assistant/ url: https://arduinojson.org/v7/assistant/
about: An online tool that computes memory requirements and generates scaffolding code for your project. about: An online tool that computes memory requirements and generates scaffolding code for your project.
- name: 👨‍⚕️ ArduinoJson Troubleshooter - name: 👨‍⚕️ ArduinoJson Troubleshooter
url: https://arduinojson.org/v6/troubleshooter/ url: https://arduinojson.org/v7/troubleshooter/
about: An online tool that helps you diagnose the most common issues with ArduinoJson. about: An online tool that helps you diagnose the most common issues with ArduinoJson.

View File

@ -15,7 +15,7 @@ A clear and concise description of what you're trying to do.
You don't need to explain every aspect of your project: focus on the problem you're having. You don't need to explain every aspect of your project: focus on the problem you're having.
**Troubleshooter report** **Troubleshooter report**
Here is the report generated by the [ArduinoJson Troubleshooter](https://arduinojson.org/v6/troubleshooter/): Here is the report generated by the [ArduinoJson Troubleshooter](https://arduinojson.org/v7/troubleshooter/):
[Paste the report here] [Paste the report here]
**Environment** **Environment**

View File

@ -15,28 +15,28 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
## Features ## Features
* [JSON deserialization](https://arduinojson.org/v6/api/json/deserializejson/) * [JSON deserialization](https://arduinojson.org/v7/api/json/deserializejson/)
* [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v6/api/config/decode_unicode/) * [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v7/api/config/decode_unicode/)
* [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/) * [Optionally supports comments in the input](https://arduinojson.org/v7/api/config/enable_comments/)
* [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/#filtering) * [Optionally filters the input to keep only desired values](https://arduinojson.org/v7/api/json/deserializejson/#filtering)
* Supports single quotes as a string delimiter * Supports single quotes as a string delimiter
* Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/) * Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/)
* [JSON serialization](https://arduinojson.org/v6/api/json/serializejson/) * [JSON serialization](https://arduinojson.org/v7/api/json/serializejson/)
* [Can write to a buffer or a stream](https://arduinojson.org/v6/api/json/serializejson/) * [Can write to a buffer or a stream](https://arduinojson.org/v7/api/json/serializejson/)
* [Optionally indents the document (prettified JSON)](https://arduinojson.org/v6/api/json/serializejsonpretty/) * [Optionally indents the document (prettified JSON)](https://arduinojson.org/v7/api/json/serializejsonpretty/)
* [MessagePack serialization](https://arduinojson.org/v6/api/msgpack/serializemsgpack/) * [MessagePack serialization](https://arduinojson.org/v7/api/msgpack/serializemsgpack/)
* [MessagePack deserialization](https://arduinojson.org/v6/api/msgpack/deserializemsgpack/) * [MessagePack deserialization](https://arduinojson.org/v7/api/msgpack/deserializemsgpack/)
* Efficient * Efficient
* [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) * [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
* [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) * [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
* [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
* [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/) * [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/)
* Versatile * Versatile
* Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/) * Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v7/how-to/use-external-ram-on-esp32/)
* Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/), and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/) * Supports [`String`](https://arduinojson.org/v7/api/config/enable_arduino_string/), [`std::string`](https://arduinojson.org/v7/api/config/enable_std_string/), and [`std::string_view`](https://arduinojson.org/v7/api/config/enable_string_view/)
* Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/) * Supports [`Stream`](https://arduinojson.org/v7/api/config/enable_arduino_stream/) and [`std::istream`/`std::ostream`](https://arduinojson.org/v7/api/config/enable_std_stream/)
* Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/) * Supports [Flash strings](https://arduinojson.org/v7/api/config/enable_progmem/)
* Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/#custom-writer) * Supports [custom readers](https://arduinojson.org/v7/api/json/deserializejson/#custom-reader) and [custom writers](https://arduinojson.org/v7/api/json/serializejson/#custom-writer)
* Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/) * Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/)
* Portable * Portable
* Usable on any C++ project (not limited to Arduino) * Usable on any C++ project (not limited to Arduino)
@ -66,15 +66,15 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [Visual Micro](http://www.visualmicro.com/) * [Visual Micro](http://www.visualmicro.com/)
* [Visual Studio](https://www.visualstudio.com/) * [Visual Studio](https://www.visualstudio.com/)
* [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN) * [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN)
* [CMake friendly](https://arduinojson.org/v6/how-to/use-arduinojson-with-cmake/) * [CMake friendly](https://arduinojson.org/v7/how-to/use-arduinojson-with-cmake/)
* Well designed * Well designed
* [Elegant API](http://arduinojson.org/v6/example/) * [Elegant API](http://arduinojson.org/v7/example/)
* [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety) * [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety)
* Self-contained (no external dependency) * Self-contained (no external dependency)
* `const` friendly * `const` friendly
* [`for` friendly](https://arduinojson.org/v6/api/jsonobject/begin_end/) * [`for` friendly](https://arduinojson.org/v7/api/jsonobject/begin_end/)
* [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming) * [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming)
* Handles [integer overflows](https://arduinojson.org/v6/api/jsonvariant/as/#integer-overflows) * Handles [integer overflows](https://arduinojson.org/v7/api/jsonvariant/as/#integer-overflows)
* Well tested * Well tested
* [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=7.x) * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=7.x)
* Continuously tested on * Continuously tested on
@ -84,11 +84,11 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
* Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/) * Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/)
* Well documented * Well documented
* [Tutorials](https://arduinojson.org/v6/doc/deserialization/) * [Tutorials](https://arduinojson.org/v7/doc/deserialization/)
* [Examples](https://arduinojson.org/v6/example/) * [Examples](https://arduinojson.org/v7/example/)
* [How-tos](https://arduinojson.org/v6/example/) * [How-tos](https://arduinojson.org/v7/example/)
* [FAQ](https://arduinojson.org/v6/faq/) * [FAQ](https://arduinojson.org/v7/faq/)
* [Troubleshooter](https://arduinojson.org/v6/troubleshooter/) * [Troubleshooter](https://arduinojson.org/v7/troubleshooter/)
* [Book](https://arduinojson.org/book/) * [Book](https://arduinojson.org/book/)
* [Changelog](CHANGELOG.md) * [Changelog](CHANGELOG.md)
* Vibrant user community * Vibrant user community
@ -114,7 +114,7 @@ double latitude = doc["data"][0];
double longitude = doc["data"][1]; double longitude = doc["data"][1];
``` ```
See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/deserialization/) See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/deserialization/)
### Serialization ### Serialization
@ -133,7 +133,7 @@ serializeJson(doc, Serial);
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
``` ```
See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/serialization/) See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/serialization/)
## Sponsors ## Sponsors

View File

@ -17,7 +17,7 @@
// * CLK <-> pin 13 // * CLK <-> pin 13
// * CS <-> pin 4 // * CS <-> pin 4
// //
// https://arduinojson.org/v6/example/config/ // https://arduinojson.org/v7/example/config/
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <SD.h> #include <SD.h>
@ -136,7 +136,7 @@ void loop() {
// ------------------ // ------------------
// //
// File is an unbuffered stream, which is not optimal for ArduinoJson. // File is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/ // See: https://arduinojson.org/v7/how-to/improve-speed/
// See also // See also
// -------- // --------

View File

@ -4,7 +4,7 @@
// //
// This example shows how to use DeserializationOption::Filter // This example shows how to use DeserializationOption::Filter
// //
// https://arduinojson.org/v6/example/filter/ // https://arduinojson.org/v7/example/filter/
#include <ArduinoJson.h> #include <ArduinoJson.h>

View File

@ -4,7 +4,7 @@
// //
// This example shows how to generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.
// //
// https://arduinojson.org/v6/example/generator/ // https://arduinojson.org/v7/example/generator/
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -21,12 +21,12 @@ void setup() {
doc["sensor"] = "gps"; doc["sensor"] = "gps";
doc["time"] = 1351824120; doc["time"] = 1351824120;
// Add an array. // Add an array
JsonArray data = doc["data"].to<JsonArray>(); JsonArray data = doc["data"].to<JsonArray>();
data.add(48.756080); data.add(48.756080);
data.add(2.302038); data.add(2.302038);
// Generate the minified JSON and send it to the Serial port. // Generate the minified JSON and send it to the Serial port
serializeJson(doc, Serial); serializeJson(doc, Serial);
// The above line prints: // The above line prints:
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
@ -34,7 +34,7 @@ void setup() {
// Start a new line // Start a new line
Serial.println(); Serial.println();
// Generate the prettified JSON and send it to the Serial port. // Generate the prettified JSON and send it to the Serial port
serializeJsonPretty(doc, Serial); serializeJsonPretty(doc, Serial);
// The above line prints: // The above line prints:
// { // {

View File

@ -16,7 +16,7 @@
// ] // ]
// } // }
// //
// https://arduinojson.org/v6/example/http-client/ // https://arduinojson.org/v7/example/http-client/
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <Ethernet.h> #include <Ethernet.h>
@ -108,7 +108,7 @@ void loop() {
// ------------------ // ------------------
// //
// EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson. // EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/ // See: https://arduinojson.org/v7/how-to/improve-speed/
// See also // See also
// -------- // --------

View File

@ -4,7 +4,7 @@
// //
// This example shows how to deserialize a JSON document with ArduinoJson. // This example shows how to deserialize a JSON document with ArduinoJson.
// //
// https://arduinojson.org/v6/example/parser/ // https://arduinojson.org/v7/example/parser/
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -24,14 +24,14 @@ void setup() {
// Deserialize the JSON document // Deserialize the JSON document
DeserializationError error = deserializeJson(doc, json); DeserializationError error = deserializeJson(doc, json);
// Test if parsing succeeds. // Test if parsing succeeds
if (error) { if (error) {
Serial.print(F("deserializeJson() failed: ")); Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str()); Serial.println(error.f_str());
return; return;
} }
// Fetch values. // Fetch the values
// //
// Most of the time, you can rely on the implicit casts. // Most of the time, you can rely on the implicit casts.
// In other case, you can do doc["time"].as<long>(); // In other case, you can do doc["time"].as<long>();
@ -40,7 +40,7 @@ void setup() {
double latitude = doc["data"][0]; double latitude = doc["data"][0];
double longitude = doc["data"][1]; double longitude = doc["data"][1];
// Print values. // Print the values
Serial.println(sensor); Serial.println(sensor);
Serial.println(time); Serial.println(time);
Serial.println(latitude, 6); Serial.println(latitude, 6);

View File

@ -13,7 +13,7 @@
// "digital": [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0] // "digital": [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0]
// } // }
// //
// https://arduinojson.org/v6/example/http-server/ // https://arduinojson.org/v7/example/http-server/
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <Ethernet.h> #include <Ethernet.h>
@ -102,7 +102,7 @@ void loop() {
// ------------------ // ------------------
// //
// EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson. // EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/ // See: https://arduinojson.org/v7/how-to/improve-speed/
// See also // See also
// -------- // --------

View File

@ -17,7 +17,7 @@
// $ ncat -ulp 8888 // $ ncat -ulp 8888
// See https://nmap.org/ncat/ // See https://nmap.org/ncat/
// //
// https://arduinojson.org/v6/example/udp-beacon/ // https://arduinojson.org/v7/example/udp-beacon/
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <Ethernet.h> #include <Ethernet.h>
@ -90,7 +90,7 @@ void loop() {
// ------------------ // ------------------
// //
// EthernetUDP is an unbuffered stream, which is not optimal for ArduinoJson. // EthernetUDP is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/ // See: https://arduinojson.org/v7/how-to/improve-speed/
// See also // See also
// -------- // --------

View File

@ -5,7 +5,7 @@
// This example shows how to deserialize a MessagePack document with // This example shows how to deserialize a MessagePack document with
// ArduinoJson. // ArduinoJson.
// //
// https://arduinojson.org/v6/example/msgpack-parser/ // https://arduinojson.org/v7/example/msgpack-parser/
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -18,7 +18,7 @@ void setup() {
// Allocate the JSON document // Allocate the JSON document
JsonDocument doc; JsonDocument doc;
// MessagePack input string. // The MessagePack input string
uint8_t input[] = {131, 166, 115, 101, 110, 115, 111, 114, 163, 103, 112, 115, uint8_t input[] = {131, 166, 115, 101, 110, 115, 111, 114, 163, 103, 112, 115,
164, 116, 105, 109, 101, 206, 80, 147, 50, 248, 164, 100, 164, 116, 105, 109, 101, 206, 80, 147, 50, 248, 164, 100,
97, 116, 97, 146, 203, 64, 72, 96, 199, 58, 188, 148, 97, 116, 97, 146, 203, 64, 72, 96, 199, 58, 188, 148,
@ -30,16 +30,17 @@ void setup() {
// "data": [48.75608, 2.302038] // "data": [48.75608, 2.302038]
// } // }
// Parse the input
DeserializationError error = deserializeMsgPack(doc, input); DeserializationError error = deserializeMsgPack(doc, input);
// Test if parsing succeeded. // Test if parsing succeeded
if (error) { if (error) {
Serial.print("deserializeMsgPack() failed: "); Serial.print("deserializeMsgPack() failed: ");
Serial.println(error.f_str()); Serial.println(error.f_str());
return; return;
} }
// Fetch values. // Fetch the values
// //
// Most of the time, you can rely on the implicit casts. // Most of the time, you can rely on the implicit casts.
// In other case, you can do doc["time"].as<long>(); // In other case, you can do doc["time"].as<long>();
@ -48,7 +49,7 @@ void setup() {
double latitude = doc["data"][0]; double latitude = doc["data"][0];
double longitude = doc["data"][1]; double longitude = doc["data"][1];
// Print values. // Print the values
Serial.println(sensor); Serial.println(sensor);
Serial.println(time); Serial.println(time);
Serial.println(latitude, 6); Serial.println(latitude, 6);

View File

@ -9,7 +9,7 @@
// JsonDocument. Prefer plain old char*, as they are more efficient in term of // JsonDocument. Prefer plain old char*, as they are more efficient in term of
// code size, speed, and memory usage. // code size, speed, and memory usage.
// //
// https://arduinojson.org/v6/example/progmem/ // https://arduinojson.org/v7/example/progmem/
#include <ArduinoJson.h> #include <ArduinoJson.h>

View File

@ -8,7 +8,7 @@
// JsonDocument. Prefer plain old char[], as they are more efficient in term of // JsonDocument. Prefer plain old char[], as they are more efficient in term of
// code size, speed, and memory usage. // code size, speed, and memory usage.
// //
// https://arduinojson.org/v6/example/string/ // https://arduinojson.org/v7/example/string/
#include <ArduinoJson.h> #include <ArduinoJson.h>

View File

@ -8,7 +8,7 @@ ARDUINOJSON_H="$3"
cat << END cat << END
--- ---
branch: v6 branch: v7
version: $VERSION version: $VERSION
date: '$(date +'%Y-%m-%d')' date: '$(date +'%Y-%m-%d')'
$(extras/scripts/wandbox/publish.sh "$ARDUINOJSON_H") $(extras/scripts/wandbox/publish.sh "$ARDUINOJSON_H")

View File

@ -9,7 +9,7 @@
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// A proxy class to get or set an element of an array. // A proxy class to get or set an element of an array.
// https://arduinojson.org/v6/api/jsonarray/subscript/ // https://arduinojson.org/v7/api/jsonarray/subscript/
template <typename TUpstream> template <typename TUpstream>
class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>, class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>,
public VariantOperators<ElementProxy<TUpstream>> { public VariantOperators<ElementProxy<TUpstream>> {

View File

@ -12,7 +12,7 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
class JsonObject; class JsonObject;
// A reference to an array in a JsonDocument // A reference to an array in a JsonDocument
// https://arduinojson.org/v6/api/jsonarray/ // https://arduinojson.org/v7/api/jsonarray/
class JsonArray : public detail::VariantOperators<JsonArray> { class JsonArray : public detail::VariantOperators<JsonArray> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
@ -28,7 +28,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
: data_(data), resources_(resources) {} : data_(data), resources_(resources) {}
// Returns a JsonVariant pointing to the array. // Returns a JsonVariant pointing to the array.
// https://arduinojson.org/v6/api/jsonvariant/ // https://arduinojson.org/v7/api/jsonvariant/
operator JsonVariant() { operator JsonVariant() {
void* data = data_; // prevent warning cast-align void* data = data_; // prevent warning cast-align
return JsonVariant(reinterpret_cast<detail::VariantData*>(data), return JsonVariant(reinterpret_cast<detail::VariantData*>(data),
@ -36,14 +36,14 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
} }
// Returns a read-only reference to the array. // Returns a read-only reference to the array.
// https://arduinojson.org/v6/api/jsonarrayconst/ // https://arduinojson.org/v7/api/jsonarrayconst/
operator JsonArrayConst() const { operator JsonArrayConst() const {
return JsonArrayConst(data_, resources_); return JsonArrayConst(data_, resources_);
} }
// Appends a new (empty) element to the array. // Appends a new (empty) element to the array.
// Returns a reference to the new element. // Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsonarray/add/ // https://arduinojson.org/v7/api/jsonarray/add/
template <typename T> template <typename T>
typename detail::enable_if<!detail::is_same<T, JsonVariant>::value, T>::type typename detail::enable_if<!detail::is_same<T, JsonVariant>::value, T>::type
add() const { add() const {
@ -52,7 +52,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
// Appends a new (null) element to the array. // Appends a new (null) element to the array.
// Returns a reference to the new element. // Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsonarray/add/ // https://arduinojson.org/v7/api/jsonarray/add/
template <typename T> template <typename T>
typename detail::enable_if<detail::is_same<T, JsonVariant>::value, T>::type typename detail::enable_if<detail::is_same<T, JsonVariant>::value, T>::type
add() const { add() const {
@ -61,21 +61,21 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
} }
// Appends a value to the array. // Appends a value to the array.
// https://arduinojson.org/v6/api/jsonarray/add/ // https://arduinojson.org/v7/api/jsonarray/add/
template <typename T> template <typename T>
FORCE_INLINE bool add(const T& value) const { FORCE_INLINE bool add(const T& value) const {
return add<JsonVariant>().set(value); return add<JsonVariant>().set(value);
} }
// Appends a value to the array. // Appends a value to the array.
// https://arduinojson.org/v6/api/jsonarray/add/ // https://arduinojson.org/v7/api/jsonarray/add/
template <typename T> template <typename T>
FORCE_INLINE bool add(T* value) const { FORCE_INLINE bool add(T* value) const {
return add<JsonVariant>().set(value); return add<JsonVariant>().set(value);
} }
// Returns an iterator to the first element of the array. // Returns an iterator to the first element of the array.
// https://arduinojson.org/v6/api/jsonarray/begin/ // https://arduinojson.org/v7/api/jsonarray/begin/
FORCE_INLINE iterator begin() const { FORCE_INLINE iterator begin() const {
if (!data_) if (!data_)
return iterator(); return iterator();
@ -83,13 +83,13 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
} }
// Returns an iterator following the last element of the array. // Returns an iterator following the last element of the array.
// https://arduinojson.org/v6/api/jsonarray/end/ // https://arduinojson.org/v7/api/jsonarray/end/
FORCE_INLINE iterator end() const { FORCE_INLINE iterator end() const {
return iterator(); return iterator();
} }
// Copies an array. // Copies an array.
// https://arduinojson.org/v6/api/jsonarray/set/ // https://arduinojson.org/v7/api/jsonarray/set/
FORCE_INLINE bool set(JsonArrayConst src) const { FORCE_INLINE bool set(JsonArrayConst src) const {
if (!data_) if (!data_)
return false; return false;
@ -105,27 +105,27 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
// Removes the element at the specified iterator. // Removes the element at the specified iterator.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonarray/remove/ // https://arduinojson.org/v7/api/jsonarray/remove/
FORCE_INLINE void remove(iterator it) const { FORCE_INLINE void remove(iterator it) const {
detail::ArrayData::remove(data_, it.iterator_, resources_); detail::ArrayData::remove(data_, it.iterator_, resources_);
} }
// Removes the element at the specified index. // Removes the element at the specified index.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonarray/remove/ // https://arduinojson.org/v7/api/jsonarray/remove/
FORCE_INLINE void remove(size_t index) const { FORCE_INLINE void remove(size_t index) const {
detail::ArrayData::removeElement(data_, index, resources_); detail::ArrayData::removeElement(data_, index, resources_);
} }
// Removes all the elements of the array. // Removes all the elements of the array.
// ⚠️ Doesn't release the memory associated with the removed elements. // ⚠️ Doesn't release the memory associated with the removed elements.
// https://arduinojson.org/v6/api/jsonarray/clear/ // https://arduinojson.org/v7/api/jsonarray/clear/
void clear() const { void clear() const {
detail::ArrayData::clear(data_, resources_); detail::ArrayData::clear(data_, resources_);
} }
// Gets or sets the element at the specified index. // Gets or sets the element at the specified index.
// https://arduinojson.org/v6/api/jsonarray/subscript/ // https://arduinojson.org/v7/api/jsonarray/subscript/
FORCE_INLINE detail::ElementProxy<JsonArray> operator[](size_t index) const { FORCE_INLINE detail::ElementProxy<JsonArray> operator[](size_t index) const {
return {*this, index}; return {*this, index};
} }
@ -135,25 +135,25 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
} }
// Returns true if the reference is unbound. // Returns true if the reference is unbound.
// https://arduinojson.org/v6/api/jsonarray/isnull/ // https://arduinojson.org/v7/api/jsonarray/isnull/
FORCE_INLINE bool isNull() const { FORCE_INLINE bool isNull() const {
return data_ == 0; return data_ == 0;
} }
// Returns true if the reference is bound. // Returns true if the reference is bound.
// https://arduinojson.org/v6/api/jsonarray/isnull/ // https://arduinojson.org/v7/api/jsonarray/isnull/
FORCE_INLINE operator bool() const { FORCE_INLINE operator bool() const {
return data_ != 0; return data_ != 0;
} }
// Returns the depth (nesting level) of the array. // Returns the depth (nesting level) of the array.
// https://arduinojson.org/v6/api/jsonarray/nesting/ // https://arduinojson.org/v7/api/jsonarray/nesting/
FORCE_INLINE size_t nesting() const { FORCE_INLINE size_t nesting() const {
return detail::VariantData::nesting(collectionToVariant(data_), resources_); return detail::VariantData::nesting(collectionToVariant(data_), resources_);
} }
// Returns the number of elements in the array. // Returns the number of elements in the array.
// https://arduinojson.org/v6/api/jsonarray/size/ // https://arduinojson.org/v7/api/jsonarray/size/
FORCE_INLINE size_t size() const { FORCE_INLINE size_t size() const {
return data_ ? data_->size(resources_) : 0; return data_ ? data_->size(resources_) : 0;
} }

View File

@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
class JsonObject; class JsonObject;
// A read-only reference to an array in a JsonDocument // A read-only reference to an array in a JsonDocument
// https://arduinojson.org/v6/api/jsonarrayconst/ // https://arduinojson.org/v7/api/jsonarrayconst/
class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> { class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
friend class JsonArray; friend class JsonArray;
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
@ -22,7 +22,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
typedef JsonArrayConstIterator iterator; typedef JsonArrayConstIterator iterator;
// Returns an iterator to the first element of the array. // Returns an iterator to the first element of the array.
// https://arduinojson.org/v6/api/jsonarrayconst/begin/ // https://arduinojson.org/v7/api/jsonarrayconst/begin/
FORCE_INLINE iterator begin() const { FORCE_INLINE iterator begin() const {
if (!data_) if (!data_)
return iterator(); return iterator();
@ -30,7 +30,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
} }
// Returns an iterator to the element following the last element of the array. // Returns an iterator to the element following the last element of the array.
// https://arduinojson.org/v6/api/jsonarrayconst/end/ // https://arduinojson.org/v7/api/jsonarrayconst/end/
FORCE_INLINE iterator end() const { FORCE_INLINE iterator end() const {
return iterator(); return iterator();
} }
@ -44,7 +44,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
: data_(data), resources_(resources) {} : data_(data), resources_(resources) {}
// Returns the element at the specified index. // Returns the element at the specified index.
// https://arduinojson.org/v6/api/jsonarrayconst/subscript/ // https://arduinojson.org/v7/api/jsonarrayconst/subscript/
FORCE_INLINE JsonVariantConst operator[](size_t index) const { FORCE_INLINE JsonVariantConst operator[](size_t index) const {
return JsonVariantConst( return JsonVariantConst(
detail::ArrayData::getElement(data_, index, resources_), resources_); detail::ArrayData::getElement(data_, index, resources_), resources_);
@ -55,25 +55,25 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
} }
// Returns true if the reference is unbound. // Returns true if the reference is unbound.
// https://arduinojson.org/v6/api/jsonarrayconst/isnull/ // https://arduinojson.org/v7/api/jsonarrayconst/isnull/
FORCE_INLINE bool isNull() const { FORCE_INLINE bool isNull() const {
return data_ == 0; return data_ == 0;
} }
// Returns true if the reference is bound. // Returns true if the reference is bound.
// https://arduinojson.org/v6/api/jsonarrayconst/isnull/ // https://arduinojson.org/v7/api/jsonarrayconst/isnull/
FORCE_INLINE operator bool() const { FORCE_INLINE operator bool() const {
return data_ != 0; return data_ != 0;
} }
// Returns the depth (nesting level) of the array. // Returns the depth (nesting level) of the array.
// https://arduinojson.org/v6/api/jsonarrayconst/nesting/ // https://arduinojson.org/v7/api/jsonarrayconst/nesting/
FORCE_INLINE size_t nesting() const { FORCE_INLINE size_t nesting() const {
return detail::VariantData::nesting(collectionToVariant(data_), resources_); return detail::VariantData::nesting(collectionToVariant(data_), resources_);
} }
// Returns the number of elements in the array. // Returns the number of elements in the array.
// https://arduinojson.org/v6/api/jsonarrayconst/size/ // https://arduinojson.org/v7/api/jsonarrayconst/size/
FORCE_INLINE size_t size() const { FORCE_INLINE size_t size() const {
return data_ ? data_->size(resources_) : 0; return data_ ? data_->size(resources_) : 0;
} }

View File

@ -18,7 +18,7 @@ copyArray(const T& src, JsonVariant dst) {
} }
// Copies values from an array to a JsonArray or a JsonVariant. // Copies values from an array to a JsonArray or a JsonVariant.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename T, size_t N, typename TDestination> template <typename T, size_t N, typename TDestination>
inline typename detail::enable_if< inline typename detail::enable_if<
!detail::is_base_of<JsonDocument, TDestination>::value, bool>::type !detail::is_base_of<JsonDocument, TDestination>::value, bool>::type
@ -27,7 +27,7 @@ copyArray(T (&src)[N], const TDestination& dst) {
} }
// Copies values from an array to a JsonArray or a JsonVariant. // Copies values from an array to a JsonArray or a JsonVariant.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename T, typename TDestination> template <typename T, typename TDestination>
inline typename detail::enable_if< inline typename detail::enable_if<
!detail::is_base_of<JsonDocument, TDestination>::value, bool>::type !detail::is_base_of<JsonDocument, TDestination>::value, bool>::type
@ -47,14 +47,14 @@ inline bool copyArray(const char* src, size_t, const TDestination& dst) {
} }
// Copies values from an array to a JsonDocument. // Copies values from an array to a JsonDocument.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename T> template <typename T>
inline bool copyArray(const T& src, JsonDocument& dst) { inline bool copyArray(const T& src, JsonDocument& dst) {
return copyArray(src, dst.to<JsonArray>()); return copyArray(src, dst.to<JsonArray>());
} }
// Copies an array to a JsonDocument. // Copies an array to a JsonDocument.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename T> template <typename T>
inline bool copyArray(const T* src, size_t len, JsonDocument& dst) { inline bool copyArray(const T* src, size_t len, JsonDocument& dst) {
return copyArray(src, len, dst.to<JsonArray>()); return copyArray(src, len, dst.to<JsonArray>());
@ -70,14 +70,14 @@ copyArray(JsonVariantConst src, T& dst) {
} }
// Copies values from a JsonArray or JsonVariant to an array. // Copies values from a JsonArray or JsonVariant to an array.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename T, size_t N> template <typename T, size_t N>
inline size_t copyArray(JsonArrayConst src, T (&dst)[N]) { inline size_t copyArray(JsonArrayConst src, T (&dst)[N]) {
return copyArray(src, dst, N); return copyArray(src, dst, N);
} }
// Copies values from a JsonArray or JsonVariant to an array. // Copies values from a JsonArray or JsonVariant to an array.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename T> template <typename T>
inline size_t copyArray(JsonArrayConst src, T* dst, size_t len) { inline size_t copyArray(JsonArrayConst src, T* dst, size_t len) {
size_t i = 0; size_t i = 0;
@ -101,7 +101,7 @@ inline size_t copyArray(JsonVariantConst src, char (&dst)[N]) {
} }
// Copies values from a JsonDocument to an array. // Copies values from a JsonDocument to an array.
// https://arduinojson.org/v6/api/misc/copyarray/ // https://arduinojson.org/v7/api/misc/copyarray/
template <typename TSource, typename T> template <typename TSource, typename T>
inline typename detail::enable_if< inline typename detail::enable_if<
detail::is_array<T>::value && detail::is_array<T>::value &&

View File

@ -19,7 +19,7 @@ struct Reader {
int read() { int read() {
// clang-format off // clang-format off
return source_->read(); // Error here? See https://arduinojson.org/v6/invalid-input/ return source_->read(); // Error here? See https://arduinojson.org/v7/invalid-input/
// clang-format on // clang-format on
} }

View File

@ -16,7 +16,7 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// A JSON document. // A JSON document.
// https://arduinojson.org/v6/api/jsondocument/ // https://arduinojson.org/v7/api/jsondocument/
class JsonDocument : public detail::VariantOperators<const JsonDocument&> { class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
@ -65,78 +65,78 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Reduces the capacity of the memory pool to match the current usage. // Reduces the capacity of the memory pool to match the current usage.
// https://arduinojson.org/v6/api/JsonDocument/shrinktofit/ // https://arduinojson.org/v7/api/JsonDocument/shrinktofit/
void shrinkToFit() { void shrinkToFit() {
resources_.shrinkToFit(); resources_.shrinkToFit();
} }
// Casts the root to the specified type. // Casts the root to the specified type.
// https://arduinojson.org/v6/api/jsondocument/as/ // https://arduinojson.org/v7/api/jsondocument/as/
template <typename T> template <typename T>
T as() { T as() {
return getVariant().template as<T>(); return getVariant().template as<T>();
} }
// Casts the root to the specified type. // Casts the root to the specified type.
// https://arduinojson.org/v6/api/jsondocument/as/ // https://arduinojson.org/v7/api/jsondocument/as/
template <typename T> template <typename T>
T as() const { T as() const {
return getVariant().template as<T>(); return getVariant().template as<T>();
} }
// Empties the document and resets the memory pool // Empties the document and resets the memory pool
// https://arduinojson.org/v6/api/jsondocument/clear/ // https://arduinojson.org/v7/api/jsondocument/clear/
void clear() { void clear() {
resources_.clear(); resources_.clear();
data_.reset(); data_.reset();
} }
// Returns true if the root is of the specified type. // Returns true if the root is of the specified type.
// https://arduinojson.org/v6/api/jsondocument/is/ // https://arduinojson.org/v7/api/jsondocument/is/
template <typename T> template <typename T>
bool is() { bool is() {
return getVariant().template is<T>(); return getVariant().template is<T>();
} }
// Returns true if the root is of the specified type. // Returns true if the root is of the specified type.
// https://arduinojson.org/v6/api/jsondocument/is/ // https://arduinojson.org/v7/api/jsondocument/is/
template <typename T> template <typename T>
bool is() const { bool is() const {
return getVariant().template is<T>(); return getVariant().template is<T>();
} }
// Returns true if the root is null. // Returns true if the root is null.
// https://arduinojson.org/v6/api/jsondocument/isnull/ // https://arduinojson.org/v7/api/jsondocument/isnull/
bool isNull() const { bool isNull() const {
return getVariant().isNull(); return getVariant().isNull();
} }
// Returns trues if the memory pool was too small. // Returns trues if the memory pool was too small.
// https://arduinojson.org/v6/api/jsondocument/overflowed/ // https://arduinojson.org/v7/api/jsondocument/overflowed/
bool overflowed() const { bool overflowed() const {
return resources_.overflowed(); return resources_.overflowed();
} }
// Returns the depth (nesting level) of the array. // Returns the depth (nesting level) of the array.
// https://arduinojson.org/v6/api/jsondocument/nesting/ // https://arduinojson.org/v7/api/jsondocument/nesting/
size_t nesting() const { size_t nesting() const {
return data_.nesting(&resources_); return data_.nesting(&resources_);
} }
// Returns the number of elements in the root array or object. // Returns the number of elements in the root array or object.
// https://arduinojson.org/v6/api/jsondocument/size/ // https://arduinojson.org/v7/api/jsondocument/size/
size_t size() const { size_t size() const {
return data_.size(&resources_); return data_.size(&resources_);
} }
// Copies the specified document. // Copies the specified document.
// https://arduinojson.org/v6/api/jsondocument/set/ // https://arduinojson.org/v7/api/jsondocument/set/
bool set(const JsonDocument& src) { bool set(const JsonDocument& src) {
return to<JsonVariant>().set(src.as<JsonVariantConst>()); return to<JsonVariant>().set(src.as<JsonVariantConst>());
} }
// Replaces the root with the specified value. // Replaces the root with the specified value.
// https://arduinojson.org/v6/api/jsondocument/set/ // https://arduinojson.org/v7/api/jsondocument/set/
template <typename T> template <typename T>
typename detail::enable_if<!detail::is_base_of<JsonDocument, T>::value, typename detail::enable_if<!detail::is_base_of<JsonDocument, T>::value,
bool>::type bool>::type
@ -145,7 +145,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Clears the document and converts it to the specified type. // Clears the document and converts it to the specified type.
// https://arduinojson.org/v6/api/jsondocument/to/ // https://arduinojson.org/v7/api/jsondocument/to/
template <typename T> template <typename T>
typename detail::VariantTo<T>::type to() { typename detail::VariantTo<T>::type to() {
clear(); clear();
@ -153,21 +153,21 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Returns true if the root object contains the specified key. // Returns true if the root object contains the specified key.
// https://arduinojson.org/v6/api/jsondocument/containskey/ // https://arduinojson.org/v7/api/jsondocument/containskey/
template <typename TChar> template <typename TChar>
bool containsKey(TChar* key) const { bool containsKey(TChar* key) const {
return data_.getMember(detail::adaptString(key), &resources_) != 0; return data_.getMember(detail::adaptString(key), &resources_) != 0;
} }
// Returns true if the root object contains the specified key. // Returns true if the root object contains the specified key.
// https://arduinojson.org/v6/api/jsondocument/containskey/ // https://arduinojson.org/v7/api/jsondocument/containskey/
template <typename TString> template <typename TString>
bool containsKey(const TString& key) const { bool containsKey(const TString& key) const {
return data_.getMember(detail::adaptString(key), &resources_) != 0; return data_.getMember(detail::adaptString(key), &resources_) != 0;
} }
// Gets or sets a root object's member. // Gets or sets a root object's member.
// https://arduinojson.org/v6/api/jsondocument/subscript/ // https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TString> template <typename TString>
FORCE_INLINE typename detail::enable_if< FORCE_INLINE typename detail::enable_if<
detail::IsString<TString>::value, detail::IsString<TString>::value,
@ -177,7 +177,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Gets or sets a root object's member. // Gets or sets a root object's member.
// https://arduinojson.org/v6/api/jsondocument/subscript/ // https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename detail::enable_if< FORCE_INLINE typename detail::enable_if<
detail::IsString<TChar*>::value, detail::IsString<TChar*>::value,
@ -187,7 +187,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Gets a root object's member. // Gets a root object's member.
// https://arduinojson.org/v6/api/jsondocument/subscript/ // https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TString> template <typename TString>
FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value,
JsonVariantConst>::type JsonVariantConst>::type
@ -197,7 +197,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Gets a root object's member. // Gets a root object's member.
// https://arduinojson.org/v6/api/jsondocument/subscript/ // https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value,
JsonVariantConst>::type JsonVariantConst>::type
@ -207,20 +207,20 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Gets or sets a root array's element. // Gets or sets a root array's element.
// https://arduinojson.org/v6/api/jsondocument/subscript/ // https://arduinojson.org/v7/api/jsondocument/subscript/
FORCE_INLINE detail::ElementProxy<JsonDocument&> operator[](size_t index) { FORCE_INLINE detail::ElementProxy<JsonDocument&> operator[](size_t index) {
return {*this, index}; return {*this, index};
} }
// Gets a root array's member. // Gets a root array's member.
// https://arduinojson.org/v6/api/jsondocument/subscript/ // https://arduinojson.org/v7/api/jsondocument/subscript/
FORCE_INLINE JsonVariantConst operator[](size_t index) const { FORCE_INLINE JsonVariantConst operator[](size_t index) const {
return JsonVariantConst(data_.getElement(index, &resources_), &resources_); return JsonVariantConst(data_.getElement(index, &resources_), &resources_);
} }
// Appends a new (empty) element to the root array. // Appends a new (empty) element to the root array.
// Returns a reference to the new element. // Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsondocument/add/ // https://arduinojson.org/v7/api/jsondocument/add/
template <typename T> template <typename T>
typename detail::enable_if<!detail::is_same<T, JsonVariant>::value, T>::type typename detail::enable_if<!detail::is_same<T, JsonVariant>::value, T>::type
add() { add() {
@ -229,7 +229,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Appends a new (null) element to the root array. // Appends a new (null) element to the root array.
// Returns a reference to the new element. // Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsondocument/add/ // https://arduinojson.org/v7/api/jsondocument/add/
template <typename T> template <typename T>
typename detail::enable_if<detail::is_same<T, JsonVariant>::value, T>::type typename detail::enable_if<detail::is_same<T, JsonVariant>::value, T>::type
add() { add() {
@ -237,14 +237,14 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
} }
// Appends a value to the root array. // Appends a value to the root array.
// https://arduinojson.org/v6/api/jsondocument/add/ // https://arduinojson.org/v7/api/jsondocument/add/
template <typename TValue> template <typename TValue>
FORCE_INLINE bool add(const TValue& value) { FORCE_INLINE bool add(const TValue& value) {
return add<JsonVariant>().set(value); return add<JsonVariant>().set(value);
} }
// Appends a value to the root array. // Appends a value to the root array.
// https://arduinojson.org/v6/api/jsondocument/add/ // https://arduinojson.org/v7/api/jsondocument/add/
template <typename TChar> template <typename TChar>
FORCE_INLINE bool add(TChar* value) { FORCE_INLINE bool add(TChar* value) {
return add<JsonVariant>().set(value); return add<JsonVariant>().set(value);
@ -252,14 +252,14 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Removes an element of the root array. // Removes an element of the root array.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsondocument/remove/ // https://arduinojson.org/v7/api/jsondocument/remove/
FORCE_INLINE void remove(size_t index) { FORCE_INLINE void remove(size_t index) {
detail::VariantData::removeElement(getData(), index, getResourceManager()); detail::VariantData::removeElement(getData(), index, getResourceManager());
} }
// Removes a member of the root object. // Removes a member of the root object.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsondocument/remove/ // https://arduinojson.org/v7/api/jsondocument/remove/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value>::type FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value>::type
remove(TChar* key) { remove(TChar* key) {
@ -269,7 +269,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Removes a member of the root object. // Removes a member of the root object.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsondocument/remove/ // https://arduinojson.org/v7/api/jsondocument/remove/
template <typename TString> template <typename TString>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TString>::value>::type typename detail::enable_if<detail::IsString<TString>::value>::type

View File

@ -669,7 +669,7 @@ ARDUINOJSON_END_PRIVATE_NAMESPACE
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// Parses a JSON input, filters, and puts the result in a JsonDocument. // Parses a JSON input, filters, and puts the result in a JsonDocument.
// https://arduinojson.org/v6/api/json/deserializejson/ // https://arduinojson.org/v7/api/json/deserializejson/
template <typename TDestination, typename... Args> template <typename TDestination, typename... Args>
typename detail::enable_if< typename detail::enable_if<
detail::is_deserialize_destination<TDestination>::value, detail::is_deserialize_destination<TDestination>::value,
@ -681,7 +681,7 @@ deserializeJson(TDestination&& dst, Args&&... args) {
} }
// Parses a JSON input, filters, and puts the result in a JsonDocument. // Parses a JSON input, filters, and puts the result in a JsonDocument.
// https://arduinojson.org/v6/api/json/deserializejson/ // https://arduinojson.org/v7/api/json/deserializejson/
template <typename TDestination, typename TChar, typename... Args> template <typename TDestination, typename TChar, typename... Args>
typename detail::enable_if< typename detail::enable_if<
detail::is_deserialize_destination<TDestination>::value, detail::is_deserialize_destination<TDestination>::value,

View File

@ -124,7 +124,7 @@ ARDUINOJSON_END_PRIVATE_NAMESPACE
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// Produces a minified JSON document. // Produces a minified JSON document.
// https://arduinojson.org/v6/api/json/serializejson/ // https://arduinojson.org/v7/api/json/serializejson/
template <typename TDestination> template <typename TDestination>
size_t serializeJson(JsonVariantConst source, TDestination& destination) { size_t serializeJson(JsonVariantConst source, TDestination& destination) {
using namespace detail; using namespace detail;
@ -132,7 +132,7 @@ size_t serializeJson(JsonVariantConst source, TDestination& destination) {
} }
// Produces a minified JSON document. // Produces a minified JSON document.
// https://arduinojson.org/v6/api/json/serializejson/ // https://arduinojson.org/v7/api/json/serializejson/
inline size_t serializeJson(JsonVariantConst source, void* buffer, inline size_t serializeJson(JsonVariantConst source, void* buffer,
size_t bufferSize) { size_t bufferSize) {
using namespace detail; using namespace detail;
@ -140,7 +140,7 @@ inline size_t serializeJson(JsonVariantConst source, void* buffer,
} }
// Computes the length of the document that serializeJson() produces. // Computes the length of the document that serializeJson() produces.
// https://arduinojson.org/v6/api/json/measurejson/ // https://arduinojson.org/v7/api/json/measurejson/
inline size_t measureJson(JsonVariantConst source) { inline size_t measureJson(JsonVariantConst source) {
using namespace detail; using namespace detail;
return measure<JsonSerializer>(source); return measure<JsonSerializer>(source);

View File

@ -79,7 +79,7 @@ ARDUINOJSON_END_PRIVATE_NAMESPACE
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// Produces JsonDocument to create a prettified JSON document. // Produces JsonDocument to create a prettified JSON document.
// https://arduinojson.org/v6/api/json/serializejsonpretty/ // https://arduinojson.org/v7/api/json/serializejsonpretty/
template <typename TDestination> template <typename TDestination>
size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) { size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) {
using namespace ArduinoJson::detail; using namespace ArduinoJson::detail;
@ -87,7 +87,7 @@ size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) {
} }
// Produces JsonDocument to create a prettified JSON document. // Produces JsonDocument to create a prettified JSON document.
// https://arduinojson.org/v6/api/json/serializejsonpretty/ // https://arduinojson.org/v7/api/json/serializejsonpretty/
inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer, inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer,
size_t bufferSize) { size_t bufferSize) {
using namespace ArduinoJson::detail; using namespace ArduinoJson::detail;
@ -95,7 +95,7 @@ inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer,
} }
// Computes the length of the document that serializeJsonPretty() produces. // Computes the length of the document that serializeJsonPretty() produces.
// https://arduinojson.org/v6/api/json/measurejsonpretty/ // https://arduinojson.org/v7/api/json/measurejsonpretty/
inline size_t measureJsonPretty(JsonVariantConst source) { inline size_t measureJsonPretty(JsonVariantConst source) {
using namespace ArduinoJson::detail; using namespace ArduinoJson::detail;
return measure<PrettyJsonSerializer>(source); return measure<PrettyJsonSerializer>(source);

View File

@ -559,7 +559,7 @@ ARDUINOJSON_END_PRIVATE_NAMESPACE
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// Parses a MessagePack input and puts the result in a JsonDocument. // Parses a MessagePack input and puts the result in a JsonDocument.
// https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ // https://arduinojson.org/v7/api/msgpack/deserializemsgpack/
template <typename TDestination, typename... Args> template <typename TDestination, typename... Args>
typename detail::enable_if< typename detail::enable_if<
detail::is_deserialize_destination<TDestination>::value, detail::is_deserialize_destination<TDestination>::value,
@ -571,7 +571,7 @@ deserializeMsgPack(TDestination&& dst, Args&&... args) {
} }
// Parses a MessagePack input and puts the result in a JsonDocument. // Parses a MessagePack input and puts the result in a JsonDocument.
// https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ // https://arduinojson.org/v7/api/msgpack/deserializemsgpack/
template <typename TDestination, typename TChar, typename... Args> template <typename TDestination, typename TChar, typename... Args>
typename detail::enable_if< typename detail::enable_if<
detail::is_deserialize_destination<TDestination>::value, detail::is_deserialize_destination<TDestination>::value,

View File

@ -211,7 +211,7 @@ ARDUINOJSON_END_PRIVATE_NAMESPACE
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// Produces a MessagePack document. // Produces a MessagePack document.
// https://arduinojson.org/v6/api/msgpack/serializemsgpack/ // https://arduinojson.org/v7/api/msgpack/serializemsgpack/
template <typename TDestination> template <typename TDestination>
inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) {
using namespace ArduinoJson::detail; using namespace ArduinoJson::detail;
@ -219,7 +219,7 @@ inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) {
} }
// Produces a MessagePack document. // Produces a MessagePack document.
// https://arduinojson.org/v6/api/msgpack/serializemsgpack/ // https://arduinojson.org/v7/api/msgpack/serializemsgpack/
inline size_t serializeMsgPack(JsonVariantConst source, void* output, inline size_t serializeMsgPack(JsonVariantConst source, void* output,
size_t size) { size_t size) {
using namespace ArduinoJson::detail; using namespace ArduinoJson::detail;
@ -227,7 +227,7 @@ inline size_t serializeMsgPack(JsonVariantConst source, void* output,
} }
// Computes the length of the document that serializeMsgPack() produces. // Computes the length of the document that serializeMsgPack() produces.
// https://arduinojson.org/v6/api/msgpack/measuremsgpack/ // https://arduinojson.org/v7/api/msgpack/measuremsgpack/
inline size_t measureMsgPack(JsonVariantConst source) { inline size_t measureMsgPack(JsonVariantConst source) {
using namespace ArduinoJson::detail; using namespace ArduinoJson::detail;
return measure<MsgPackSerializer>(source); return measure<MsgPackSerializer>(source);

View File

@ -25,4 +25,4 @@ ARDUINOJSON_END_PUBLIC_NAMESPACE
static_assert(sizeof(T) <= sizeof(ArduinoJson::JsonInteger), \ static_assert(sizeof(T) <= sizeof(ArduinoJson::JsonInteger), \
"To use 64-bit integers with ArduinoJson, you must set " \ "To use 64-bit integers with ArduinoJson, you must set " \
"ARDUINOJSON_USE_LONG_LONG to 1. See " \ "ARDUINOJSON_USE_LONG_LONG to 1. See " \
"https://arduinojson.org/v6/api/config/use_long_long/"); "https://arduinojson.org/v7/api/config/use_long_long/");

View File

@ -12,7 +12,7 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
class JsonArray; class JsonArray;
// A reference to an object in a JsonDocument. // A reference to an object in a JsonDocument.
// https://arduinojson.org/v6/api/jsonobject/ // https://arduinojson.org/v7/api/jsonobject/
class JsonObject : public detail::VariantOperators<JsonObject> { class JsonObject : public detail::VariantOperators<JsonObject> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
@ -42,31 +42,31 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
} }
// Returns true if the reference is unbound. // Returns true if the reference is unbound.
// https://arduinojson.org/v6/api/jsonobject/isnull/ // https://arduinojson.org/v7/api/jsonobject/isnull/
FORCE_INLINE bool isNull() const { FORCE_INLINE bool isNull() const {
return data_ == 0; return data_ == 0;
} }
// Returns true if the reference is bound. // Returns true if the reference is bound.
// https://arduinojson.org/v6/api/jsonobject/isnull/ // https://arduinojson.org/v7/api/jsonobject/isnull/
FORCE_INLINE operator bool() const { FORCE_INLINE operator bool() const {
return data_ != 0; return data_ != 0;
} }
// Returns the depth (nesting level) of the object. // Returns the depth (nesting level) of the object.
// https://arduinojson.org/v6/api/jsonobject/nesting/ // https://arduinojson.org/v7/api/jsonobject/nesting/
FORCE_INLINE size_t nesting() const { FORCE_INLINE size_t nesting() const {
return detail::VariantData::nesting(collectionToVariant(data_), resources_); return detail::VariantData::nesting(collectionToVariant(data_), resources_);
} }
// Returns the number of members in the object. // Returns the number of members in the object.
// https://arduinojson.org/v6/api/jsonobject/size/ // https://arduinojson.org/v7/api/jsonobject/size/
FORCE_INLINE size_t size() const { FORCE_INLINE size_t size() const {
return data_ ? data_->size(resources_) : 0; return data_ ? data_->size(resources_) : 0;
} }
// Returns an iterator to the first key-value pair of the object. // Returns an iterator to the first key-value pair of the object.
// https://arduinojson.org/v6/api/jsonobject/begin/ // https://arduinojson.org/v7/api/jsonobject/begin/
FORCE_INLINE iterator begin() const { FORCE_INLINE iterator begin() const {
if (!data_) if (!data_)
return iterator(); return iterator();
@ -74,20 +74,20 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
} }
// Returns an iterator following the last key-value pair of the object. // Returns an iterator following the last key-value pair of the object.
// https://arduinojson.org/v6/api/jsonobject/end/ // https://arduinojson.org/v7/api/jsonobject/end/
FORCE_INLINE iterator end() const { FORCE_INLINE iterator end() const {
return iterator(); return iterator();
} }
// Removes all the members of the object. // Removes all the members of the object.
// ⚠️ Doesn't release the memory associated with the removed members. // ⚠️ Doesn't release the memory associated with the removed members.
// https://arduinojson.org/v6/api/jsonobject/clear/ // https://arduinojson.org/v7/api/jsonobject/clear/
void clear() const { void clear() const {
detail::ObjectData::clear(data_, resources_); detail::ObjectData::clear(data_, resources_);
} }
// Copies an object. // Copies an object.
// https://arduinojson.org/v6/api/jsonobject/set/ // https://arduinojson.org/v7/api/jsonobject/set/
FORCE_INLINE bool set(JsonObjectConst src) { FORCE_INLINE bool set(JsonObjectConst src) {
if (!data_ || !src.data_) if (!data_ || !src.data_)
return false; return false;
@ -102,7 +102,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
} }
// Gets or sets the member with specified key. // Gets or sets the member with specified key.
// https://arduinojson.org/v6/api/jsonobject/subscript/ // https://arduinojson.org/v7/api/jsonobject/subscript/
template <typename TString> template <typename TString>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TString>::value, typename detail::enable_if<detail::IsString<TString>::value,
@ -112,7 +112,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
} }
// Gets or sets the member with specified key. // Gets or sets the member with specified key.
// https://arduinojson.org/v6/api/jsonobject/subscript/ // https://arduinojson.org/v7/api/jsonobject/subscript/
template <typename TChar> template <typename TChar>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TChar*>::value, typename detail::enable_if<detail::IsString<TChar*>::value,
@ -123,14 +123,14 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
// Removes the member at the specified iterator. // Removes the member at the specified iterator.
// ⚠️ Doesn't release the memory associated with the removed member. // ⚠️ Doesn't release the memory associated with the removed member.
// https://arduinojson.org/v6/api/jsonobject/remove/ // https://arduinojson.org/v7/api/jsonobject/remove/
FORCE_INLINE void remove(iterator it) const { FORCE_INLINE void remove(iterator it) const {
detail::ObjectData::remove(data_, it.iterator_, resources_); detail::ObjectData::remove(data_, it.iterator_, resources_);
} }
// Removes the member with the specified key. // Removes the member with the specified key.
// ⚠️ Doesn't release the memory associated with the removed member. // ⚠️ Doesn't release the memory associated with the removed member.
// https://arduinojson.org/v6/api/jsonobject/remove/ // https://arduinojson.org/v7/api/jsonobject/remove/
template <typename TString> template <typename TString>
FORCE_INLINE void remove(const TString& key) const { FORCE_INLINE void remove(const TString& key) const {
detail::ObjectData::removeMember(data_, detail::adaptString(key), detail::ObjectData::removeMember(data_, detail::adaptString(key),
@ -139,7 +139,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
// Removes the member with the specified key. // Removes the member with the specified key.
// ⚠️ Doesn't release the memory associated with the removed member. // ⚠️ Doesn't release the memory associated with the removed member.
// https://arduinojson.org/v6/api/jsonobject/remove/ // https://arduinojson.org/v7/api/jsonobject/remove/
template <typename TChar> template <typename TChar>
FORCE_INLINE void remove(TChar* key) const { FORCE_INLINE void remove(TChar* key) const {
detail::ObjectData::removeMember(data_, detail::adaptString(key), detail::ObjectData::removeMember(data_, detail::adaptString(key),
@ -147,7 +147,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
} }
// Returns true if the object contains the specified key. // Returns true if the object contains the specified key.
// https://arduinojson.org/v6/api/jsonobject/containskey/ // https://arduinojson.org/v7/api/jsonobject/containskey/
template <typename TString> template <typename TString>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TString>::value, bool>::type typename detail::enable_if<detail::IsString<TString>::value, bool>::type
@ -157,7 +157,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
} }
// Returns true if the object contains the specified key. // Returns true if the object contains the specified key.
// https://arduinojson.org/v6/api/jsonobject/containskey/ // https://arduinojson.org/v7/api/jsonobject/containskey/
template <typename TChar> template <typename TChar>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type

View File

@ -10,7 +10,7 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// A read-only reference to an object in a JsonDocument. // A read-only reference to an object in a JsonDocument.
// https://arduinojson.org/v6/api/jsonobjectconst/ // https://arduinojson.org/v7/api/jsonobjectconst/
class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> { class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
friend class JsonObject; friend class JsonObject;
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
@ -31,31 +31,31 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
} }
// Returns true if the reference is unbound. // Returns true if the reference is unbound.
// https://arduinojson.org/v6/api/jsonobjectconst/isnull/ // https://arduinojson.org/v7/api/jsonobjectconst/isnull/
FORCE_INLINE bool isNull() const { FORCE_INLINE bool isNull() const {
return data_ == 0; return data_ == 0;
} }
// Returns true if the reference is bound. // Returns true if the reference is bound.
// https://arduinojson.org/v6/api/jsonobjectconst/isnull/ // https://arduinojson.org/v7/api/jsonobjectconst/isnull/
FORCE_INLINE operator bool() const { FORCE_INLINE operator bool() const {
return data_ != 0; return data_ != 0;
} }
// Returns the depth (nesting level) of the object. // Returns the depth (nesting level) of the object.
// https://arduinojson.org/v6/api/jsonobjectconst/nesting/ // https://arduinojson.org/v7/api/jsonobjectconst/nesting/
FORCE_INLINE size_t nesting() const { FORCE_INLINE size_t nesting() const {
return detail::VariantData::nesting(collectionToVariant(data_), resources_); return detail::VariantData::nesting(collectionToVariant(data_), resources_);
} }
// Returns the number of members in the object. // Returns the number of members in the object.
// https://arduinojson.org/v6/api/jsonobjectconst/size/ // https://arduinojson.org/v7/api/jsonobjectconst/size/
FORCE_INLINE size_t size() const { FORCE_INLINE size_t size() const {
return data_ ? data_->size(resources_) : 0; return data_ ? data_->size(resources_) : 0;
} }
// Returns an iterator to the first key-value pair of the object. // Returns an iterator to the first key-value pair of the object.
// https://arduinojson.org/v6/api/jsonobjectconst/begin/ // https://arduinojson.org/v7/api/jsonobjectconst/begin/
FORCE_INLINE iterator begin() const { FORCE_INLINE iterator begin() const {
if (!data_) if (!data_)
return iterator(); return iterator();
@ -63,13 +63,13 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
} }
// Returns an iterator following the last key-value pair of the object. // Returns an iterator following the last key-value pair of the object.
// https://arduinojson.org/v6/api/jsonobjectconst/end/ // https://arduinojson.org/v7/api/jsonobjectconst/end/
FORCE_INLINE iterator end() const { FORCE_INLINE iterator end() const {
return iterator(); return iterator();
} }
// Returns true if the object contains the specified key. // Returns true if the object contains the specified key.
// https://arduinojson.org/v6/api/jsonobjectconst/containskey/ // https://arduinojson.org/v7/api/jsonobjectconst/containskey/
template <typename TString> template <typename TString>
FORCE_INLINE bool containsKey(const TString& key) const { FORCE_INLINE bool containsKey(const TString& key) const {
return detail::ObjectData::getMember(data_, detail::adaptString(key), return detail::ObjectData::getMember(data_, detail::adaptString(key),
@ -77,7 +77,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
} }
// Returns true if the object contains the specified key. // Returns true if the object contains the specified key.
// https://arduinojson.org/v6/api/jsonobjectconst/containskey/ // https://arduinojson.org/v7/api/jsonobjectconst/containskey/
template <typename TChar> template <typename TChar>
FORCE_INLINE bool containsKey(TChar* key) const { FORCE_INLINE bool containsKey(TChar* key) const {
return detail::ObjectData::getMember(data_, detail::adaptString(key), return detail::ObjectData::getMember(data_, detail::adaptString(key),
@ -85,7 +85,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
} }
// Gets the member with specified key. // Gets the member with specified key.
// https://arduinojson.org/v6/api/jsonobjectconst/subscript/ // https://arduinojson.org/v7/api/jsonobjectconst/subscript/
template <typename TString> template <typename TString>
FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value,
JsonVariantConst>::type JsonVariantConst>::type
@ -96,7 +96,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
} }
// Gets the member with specified key. // Gets the member with specified key.
// https://arduinojson.org/v6/api/jsonobjectconst/subscript/ // https://arduinojson.org/v7/api/jsonobjectconst/subscript/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value,
JsonVariantConst>::type JsonVariantConst>::type

View File

@ -11,7 +11,7 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// A key-value pair. // A key-value pair.
// https://arduinojson.org/v6/api/jsonobject/begin_end/ // https://arduinojson.org/v7/api/jsonobject/begin_end/
class JsonPair { class JsonPair {
public: public:
// INTERNAL USE ONLY // INTERNAL USE ONLY
@ -40,7 +40,7 @@ class JsonPair {
}; };
// A read-only key-value pair. // A read-only key-value pair.
// https://arduinojson.org/v6/api/jsonobjectconst/begin_end/ // https://arduinojson.org/v7/api/jsonobjectconst/begin_end/
class JsonPairConst { class JsonPairConst {
public: public:
JsonPairConst(detail::ObjectData::iterator iterator, JsonPairConst(detail::ObjectData::iterator iterator,

View File

@ -9,7 +9,7 @@
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// A proxy class to get or set a member of an object. // A proxy class to get or set a member of an object.
// https://arduinojson.org/v6/api/jsonobject/subscript/ // https://arduinojson.org/v7/api/jsonobject/subscript/
template <typename TUpstream, typename TStringRef> template <typename TUpstream, typename TStringRef>
class MemberProxy class MemberProxy
: public VariantRefBase<MemberProxy<TUpstream, TStringRef>>, : public VariantRefBase<MemberProxy<TUpstream, TStringRef>>,

View File

@ -11,7 +11,7 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// A string. // A string.
// https://arduinojson.org/v6/api/jsonstring/ // https://arduinojson.org/v7/api/jsonstring/
class JsonString { class JsonString {
public: public:
enum Ownership { Copied, Linked }; enum Ownership { Copied, Linked };

View File

@ -17,7 +17,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// clang-format off // clang-format off
template <typename T1, typename T2> template <typename T1, typename T2>
class InvalidConversion; // Error here? See https://arduinojson.org/v6/invalid-conversion/ class InvalidConversion; // Error here? See https://arduinojson.org/v7/invalid-conversion/
// clang-format on // clang-format on
template <typename T> template <typename T>

View File

@ -15,14 +15,14 @@ template <typename T, typename Enable>
struct Converter { struct Converter {
static void toJson(const T& src, JsonVariant dst) { static void toJson(const T& src, JsonVariant dst) {
// clang-format off // clang-format off
convertToJson(src, dst); // Error here? See https://arduinojson.org/v6/unsupported-set/ convertToJson(src, dst); // Error here? See https://arduinojson.org/v7/unsupported-set/
// clang-format on // clang-format on
} }
static T fromJson(JsonVariantConst src) { static T fromJson(JsonVariantConst src) {
// clang-format off // clang-format off
T result; // Error here? See https://arduinojson.org/v6/non-default-constructible/ T result; // Error here? See https://arduinojson.org/v7/non-default-constructible/
convertFromJson(src, result); // Error here? See https://arduinojson.org/v6/unsupported-as/ convertFromJson(src, result); // Error here? See https://arduinojson.org/v7/unsupported-as/
// clang-format on // clang-format on
return result; return result;
} }
@ -30,7 +30,7 @@ struct Converter {
static bool checkJson(JsonVariantConst src) { static bool checkJson(JsonVariantConst src) {
T dummy = T(); T dummy = T();
// clang-format off // clang-format off
return canConvertFromJson(src, dummy); // Error here? See https://arduinojson.org/v6/unsupported-is/ return canConvertFromJson(src, dummy); // Error here? See https://arduinojson.org/v7/unsupported-is/
// clang-format on // clang-format on
} }
}; };

View File

@ -9,7 +9,7 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
// A reference to a value in a JsonDocument. // A reference to a value in a JsonDocument.
// https://arduinojson.org/v6/api/jsonvariant/ // https://arduinojson.org/v7/api/jsonvariant/
class JsonVariant : public detail::VariantRefBase<JsonVariant>, class JsonVariant : public detail::VariantRefBase<JsonVariant>,
public detail::VariantOperators<JsonVariant> { public detail::VariantOperators<JsonVariant> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;

View File

@ -22,7 +22,7 @@ class JsonArray;
class JsonObject; class JsonObject;
// A read-only reference to a value in a JsonDocument // A read-only reference to a value in a JsonDocument
// https://arduinojson.org/v6/api/jsonarrayconst/ // https://arduinojson.org/v7/api/jsonarrayconst/
class JsonVariantConst : public detail::VariantTag, class JsonVariantConst : public detail::VariantTag,
public detail::VariantOperators<JsonVariantConst> { public detail::VariantOperators<JsonVariantConst> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
@ -37,7 +37,7 @@ class JsonVariantConst : public detail::VariantTag,
: data_(data), resources_(resources) {} : data_(data), resources_(resources) {}
// Returns true if the value is null or the reference is unbound. // Returns true if the value is null or the reference is unbound.
// https://arduinojson.org/v6/api/jsonvariantconst/isnull/ // https://arduinojson.org/v7/api/jsonvariantconst/isnull/
FORCE_INLINE bool isNull() const { FORCE_INLINE bool isNull() const {
return detail::VariantData::isNull(data_); return detail::VariantData::isNull(data_);
} }
@ -48,19 +48,19 @@ class JsonVariantConst : public detail::VariantTag,
} }
// Returns the depth (nesting level) of the value. // Returns the depth (nesting level) of the value.
// https://arduinojson.org/v6/api/jsonvariantconst/nesting/ // https://arduinojson.org/v7/api/jsonvariantconst/nesting/
FORCE_INLINE size_t nesting() const { FORCE_INLINE size_t nesting() const {
return detail::VariantData::nesting(data_, resources_); return detail::VariantData::nesting(data_, resources_);
} }
// Returns the size of the array or object. // Returns the size of the array or object.
// https://arduinojson.org/v6/api/jsonvariantconst/size/ // https://arduinojson.org/v7/api/jsonvariantconst/size/
size_t size() const { size_t size() const {
return detail::VariantData::size(data_, resources_); return detail::VariantData::size(data_, resources_);
} }
// Casts the value to the specified type. // Casts the value to the specified type.
// https://arduinojson.org/v6/api/jsonvariantconst/as/ // https://arduinojson.org/v7/api/jsonvariantconst/as/
template <typename T> template <typename T>
FORCE_INLINE typename detail::enable_if<!detail::is_same<T, char*>::value && FORCE_INLINE typename detail::enable_if<!detail::is_same<T, char*>::value &&
!detail::is_same<T, char>::value, !detail::is_same<T, char>::value,
@ -70,7 +70,7 @@ class JsonVariantConst : public detail::VariantTag,
} }
// Returns true if the value is of the specified type. // Returns true if the value is of the specified type.
// https://arduinojson.org/v6/api/jsonvariantconst/is/ // https://arduinojson.org/v7/api/jsonvariantconst/is/
template <typename T> template <typename T>
FORCE_INLINE typename detail::enable_if<!detail::is_same<T, char*>::value && FORCE_INLINE typename detail::enable_if<!detail::is_same<T, char*>::value &&
!detail::is_same<T, char>::value, !detail::is_same<T, char>::value,
@ -85,14 +85,14 @@ class JsonVariantConst : public detail::VariantTag,
} }
// Gets array's element at specified index. // Gets array's element at specified index.
// https://arduinojson.org/v6/api/jsonvariantconst/subscript/ // https://arduinojson.org/v7/api/jsonvariantconst/subscript/
FORCE_INLINE JsonVariantConst operator[](size_t index) const { FORCE_INLINE JsonVariantConst operator[](size_t index) const {
return JsonVariantConst( return JsonVariantConst(
detail::VariantData::getElement(data_, index, resources_), resources_); detail::VariantData::getElement(data_, index, resources_), resources_);
} }
// Gets object's member with specified key. // Gets object's member with specified key.
// https://arduinojson.org/v6/api/jsonvariantconst/subscript/ // https://arduinojson.org/v7/api/jsonvariantconst/subscript/
template <typename TString> template <typename TString>
FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value,
JsonVariantConst>::type JsonVariantConst>::type
@ -103,7 +103,7 @@ class JsonVariantConst : public detail::VariantTag,
} }
// Gets object's member with specified key. // Gets object's member with specified key.
// https://arduinojson.org/v6/api/jsonvariantconst/subscript/ // https://arduinojson.org/v7/api/jsonvariantconst/subscript/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value,
JsonVariantConst>::type JsonVariantConst>::type
@ -114,7 +114,7 @@ class JsonVariantConst : public detail::VariantTag,
} }
// Returns true if tge object contains the specified key. // Returns true if tge object contains the specified key.
// https://arduinojson.org/v6/api/jsonvariantconst/containskey/ // https://arduinojson.org/v7/api/jsonvariantconst/containskey/
template <typename TString> template <typename TString>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TString>::value, bool>::type typename detail::enable_if<detail::IsString<TString>::value, bool>::type
@ -124,7 +124,7 @@ class JsonVariantConst : public detail::VariantTag,
} }
// Returns true if tge object contains the specified key. // Returns true if tge object contains the specified key.
// https://arduinojson.org/v6/api/jsonvariantconst/containskey/ // https://arduinojson.org/v7/api/jsonvariantconst/containskey/
template <typename TChar> template <typename TChar>
FORCE_INLINE FORCE_INLINE
typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type

View File

@ -28,13 +28,13 @@ class VariantRefBase : public VariantTag {
public: public:
// Sets the value to null. // Sets the value to null.
// ⚠️ Doesn't release the memory associated with the previous value. // ⚠️ Doesn't release the memory associated with the previous value.
// https://arduinojson.org/v6/api/jsonvariant/clear/ // https://arduinojson.org/v7/api/jsonvariant/clear/
FORCE_INLINE void clear() const { FORCE_INLINE void clear() const {
VariantData::setNull(getOrCreateData(), getResourceManager()); VariantData::setNull(getOrCreateData(), getResourceManager());
} }
// Returns true if the value is null or the reference is unbound. // Returns true if the value is null or the reference is unbound.
// https://arduinojson.org/v6/api/jsonvariant/isnull/ // https://arduinojson.org/v7/api/jsonvariant/isnull/
FORCE_INLINE bool isNull() const { FORCE_INLINE bool isNull() const {
return VariantData::isNull(getData()); return VariantData::isNull(getData());
} }
@ -45,7 +45,7 @@ class VariantRefBase : public VariantTag {
} }
// Casts the value to the specified type. // Casts the value to the specified type.
// https://arduinojson.org/v6/api/jsonvariant/as/ // https://arduinojson.org/v7/api/jsonvariant/as/
template <typename T> template <typename T>
FORCE_INLINE FORCE_INLINE
typename enable_if<!ConverterNeedsWriteableRef<T>::value, T>::type typename enable_if<!ConverterNeedsWriteableRef<T>::value, T>::type
@ -54,7 +54,7 @@ class VariantRefBase : public VariantTag {
} }
// Casts the value to the specified type. // Casts the value to the specified type.
// https://arduinojson.org/v6/api/jsonvariant/as/ // https://arduinojson.org/v7/api/jsonvariant/as/
template <typename T> template <typename T>
FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
as() const { as() const {
@ -68,26 +68,26 @@ class VariantRefBase : public VariantTag {
// Sets the value to an empty array. // Sets the value to an empty array.
// ⚠️ Doesn't release the memory associated with the previous value. // ⚠️ Doesn't release the memory associated with the previous value.
// https://arduinojson.org/v6/api/jsonvariant/to/ // https://arduinojson.org/v7/api/jsonvariant/to/
template <typename T> template <typename T>
typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type to() const; typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type to() const;
// Sets the value to an empty object. // Sets the value to an empty object.
// ⚠️ Doesn't release the memory associated with the previous value. // ⚠️ Doesn't release the memory associated with the previous value.
// https://arduinojson.org/v6/api/jsonvariant/to/ // https://arduinojson.org/v7/api/jsonvariant/to/
template <typename T> template <typename T>
typename enable_if<is_same<T, JsonObject>::value, JsonObject>::type to() typename enable_if<is_same<T, JsonObject>::value, JsonObject>::type to()
const; const;
// Sets the value to null. // Sets the value to null.
// ⚠️ Doesn't release the memory associated with the previous value. // ⚠️ Doesn't release the memory associated with the previous value.
// https://arduinojson.org/v6/api/jsonvariant/to/ // https://arduinojson.org/v7/api/jsonvariant/to/
template <typename T> template <typename T>
typename enable_if<is_same<T, JsonVariant>::value, JsonVariant>::type to() typename enable_if<is_same<T, JsonVariant>::value, JsonVariant>::type to()
const; const;
// Returns true if the value is of the specified type. // Returns true if the value is of the specified type.
// https://arduinojson.org/v6/api/jsonvariant/is/ // https://arduinojson.org/v7/api/jsonvariant/is/
template <typename T> template <typename T>
FORCE_INLINE FORCE_INLINE
typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
@ -96,7 +96,7 @@ class VariantRefBase : public VariantTag {
} }
// Returns true if the value is of the specified type. // Returns true if the value is of the specified type.
// https://arduinojson.org/v6/api/jsonvariant/is/ // https://arduinojson.org/v7/api/jsonvariant/is/
template <typename T> template <typename T>
FORCE_INLINE typename enable_if<!ConverterNeedsWriteableRef<T>::value && FORCE_INLINE typename enable_if<!ConverterNeedsWriteableRef<T>::value &&
!is_same<T, char*>::value && !is_same<T, char*>::value &&
@ -107,7 +107,7 @@ class VariantRefBase : public VariantTag {
} }
// Copies the specified value. // Copies the specified value.
// https://arduinojson.org/v6/api/jsonvariant/set/ // https://arduinojson.org/v7/api/jsonvariant/set/
template <typename T> template <typename T>
FORCE_INLINE bool set(const T& value) const { FORCE_INLINE bool set(const T& value) const {
Converter<T>::toJson(value, getOrCreateVariant()); Converter<T>::toJson(value, getOrCreateVariant());
@ -116,7 +116,7 @@ class VariantRefBase : public VariantTag {
} }
// Copies the specified value. // Copies the specified value.
// https://arduinojson.org/v6/api/jsonvariant/set/ // https://arduinojson.org/v7/api/jsonvariant/set/
template <typename T> template <typename T>
FORCE_INLINE bool set(T* value) const { FORCE_INLINE bool set(T* value) const {
Converter<T*>::toJson(value, getOrCreateVariant()); Converter<T*>::toJson(value, getOrCreateVariant());
@ -125,20 +125,20 @@ class VariantRefBase : public VariantTag {
} }
// Returns the size of the array or object. // Returns the size of the array or object.
// https://arduinojson.org/v6/api/jsonvariant/size/ // https://arduinojson.org/v7/api/jsonvariant/size/
FORCE_INLINE size_t size() const { FORCE_INLINE size_t size() const {
return VariantData::size(getData(), getResourceManager()); return VariantData::size(getData(), getResourceManager());
} }
// Returns the depth (nesting level) of the value. // Returns the depth (nesting level) of the value.
// https://arduinojson.org/v6/api/jsonvariant/nesting/ // https://arduinojson.org/v7/api/jsonvariant/nesting/
FORCE_INLINE size_t nesting() const { FORCE_INLINE size_t nesting() const {
return VariantData::nesting(getData(), getResourceManager()); return VariantData::nesting(getData(), getResourceManager());
} }
// Appends a new (empty) element to the array. // Appends a new (empty) element to the array.
// Returns a reference to the new element. // Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsonvariant/add/ // https://arduinojson.org/v7/api/jsonvariant/add/
template <typename T> template <typename T>
typename enable_if<!is_same<T, JsonVariant>::value, T>::type add() const { typename enable_if<!is_same<T, JsonVariant>::value, T>::type add() const {
return add<JsonVariant>().template to<T>(); return add<JsonVariant>().template to<T>();
@ -146,19 +146,19 @@ class VariantRefBase : public VariantTag {
// Appends a new (null) element to the array. // Appends a new (null) element to the array.
// Returns a reference to the new element. // Returns a reference to the new element.
// https://arduinojson.org/v6/api/jsonvariant/add/ // https://arduinojson.org/v7/api/jsonvariant/add/
template <typename T> template <typename T>
typename enable_if<is_same<T, JsonVariant>::value, T>::type add() const; typename enable_if<is_same<T, JsonVariant>::value, T>::type add() const;
// Appends a value to the array. // Appends a value to the array.
// https://arduinojson.org/v6/api/jsonvariant/add/ // https://arduinojson.org/v7/api/jsonvariant/add/
template <typename T> template <typename T>
FORCE_INLINE bool add(const T& value) const { FORCE_INLINE bool add(const T& value) const {
return add<JsonVariant>().set(value); return add<JsonVariant>().set(value);
} }
// Appends a value to the array. // Appends a value to the array.
// https://arduinojson.org/v6/api/jsonvariant/add/ // https://arduinojson.org/v7/api/jsonvariant/add/
template <typename T> template <typename T>
FORCE_INLINE bool add(T* value) const { FORCE_INLINE bool add(T* value) const {
return add<JsonVariant>().set(value); return add<JsonVariant>().set(value);
@ -166,14 +166,14 @@ class VariantRefBase : public VariantTag {
// Removes an element of the array. // Removes an element of the array.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonvariant/remove/ // https://arduinojson.org/v7/api/jsonvariant/remove/
FORCE_INLINE void remove(size_t index) const { FORCE_INLINE void remove(size_t index) const {
VariantData::removeElement(getData(), index, getResourceManager()); VariantData::removeElement(getData(), index, getResourceManager());
} }
// Removes a member of the object. // Removes a member of the object.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonvariant/remove/ // https://arduinojson.org/v7/api/jsonvariant/remove/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove( FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove(
TChar* key) const { TChar* key) const {
@ -183,7 +183,7 @@ class VariantRefBase : public VariantTag {
// Removes a member of the object. // Removes a member of the object.
// ⚠️ Doesn't release the memory associated with the removed element. // ⚠️ Doesn't release the memory associated with the removed element.
// https://arduinojson.org/v6/api/jsonvariant/remove/ // https://arduinojson.org/v7/api/jsonvariant/remove/
template <typename TString> template <typename TString>
FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove(
const TString& key) const { const TString& key) const {
@ -192,30 +192,30 @@ class VariantRefBase : public VariantTag {
} }
// Gets or sets an array element. // Gets or sets an array element.
// https://arduinojson.org/v6/api/jsonvariant/subscript/ // https://arduinojson.org/v7/api/jsonvariant/subscript/
FORCE_INLINE ElementProxy<TDerived> operator[](size_t index) const; FORCE_INLINE ElementProxy<TDerived> operator[](size_t index) const;
// Returns true if the object contains the specified key. // Returns true if the object contains the specified key.
// https://arduinojson.org/v6/api/jsonvariant/containskey/ // https://arduinojson.org/v7/api/jsonvariant/containskey/
template <typename TString> template <typename TString>
FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type
containsKey(const TString& key) const; containsKey(const TString& key) const;
// Returns true if the object contains the specified key. // Returns true if the object contains the specified key.
// https://arduinojson.org/v6/api/jsonvariant/containskey/ // https://arduinojson.org/v7/api/jsonvariant/containskey/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type
containsKey(TChar* key) const; containsKey(TChar* key) const;
// Gets or sets an object member. // Gets or sets an object member.
// https://arduinojson.org/v6/api/jsonvariant/subscript/ // https://arduinojson.org/v7/api/jsonvariant/subscript/
template <typename TString> template <typename TString>
FORCE_INLINE typename enable_if<IsString<TString>::value, FORCE_INLINE typename enable_if<IsString<TString>::value,
MemberProxy<TDerived, TString>>::type MemberProxy<TDerived, TString>>::type
operator[](const TString& key) const; operator[](const TString& key) const;
// Gets or sets an object member. // Gets or sets an object member.
// https://arduinojson.org/v6/api/jsonvariant/subscript/ // https://arduinojson.org/v7/api/jsonvariant/subscript/
template <typename TChar> template <typename TChar>
FORCE_INLINE typename enable_if<IsString<TChar*>::value, FORCE_INLINE typename enable_if<IsString<TChar*>::value,
MemberProxy<TDerived, TChar*>>::type MemberProxy<TDerived, TChar*>>::type

View File

@ -23,7 +23,7 @@
#define ARDUINOJSON_STRINGIFY(S) #S #define ARDUINOJSON_STRINGIFY(S) #S
#define ARDUINOJSON_DEPRECATION_ERROR(X, Y) \ #define ARDUINOJSON_DEPRECATION_ERROR(X, Y) \
ARDUINOJSON_COMPILE_ERROR(ARDUINOJSON_STRINGIFY(X is a Y from ArduinoJson 5. Please see https:/\/arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6)) ARDUINOJSON_COMPILE_ERROR(ARDUINOJSON_STRINGIFY(X is a Y from ArduinoJson 5. Please see https:/\/arduinojson.org/v7/upgrade-from-v5/ to learn how to upgrade to ArduinoJson 7))
#define StaticJsonBuffer ARDUINOJSON_DEPRECATION_ERROR(StaticJsonBuffer, class) #define StaticJsonBuffer ARDUINOJSON_DEPRECATION_ERROR(StaticJsonBuffer, class)
#define DynamicJsonBuffer ARDUINOJSON_DEPRECATION_ERROR(DynamicJsonBuffer, class) #define DynamicJsonBuffer ARDUINOJSON_DEPRECATION_ERROR(DynamicJsonBuffer, class)