From 7bd2ea10725631492379beb1d37ad6a98d1fb5ce Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 19 Aug 2023 16:05:04 +0200 Subject: [PATCH] Remove mentions of the zero-copy mode --- README.md | 3 +-- .../scripts/wandbox/JsonGeneratorExample.cpp | 12 ++-------- extras/scripts/wandbox/JsonParserExample.cpp | 21 +++++------------- .../scripts/wandbox/MsgPackParserExample.cpp | 22 +++++-------------- idf_component.yml | 2 +- library.json | 2 +- library.properties | 2 +- 7 files changed, 16 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 2f918b9f..24e2ac90 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * [JSON deserialization](https://arduinojson.org/v6/api/json/deserializejson/) * [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v6/api/config/decode_unicode/) - * [Optionally stores links to the input buffer (zero-copy)](https://arduinojson.org/v6/api/json/deserializejson/) * [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/) * [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/#filtering) * Supports single quotes as a string delimiter @@ -104,7 +103,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). Here is a program that parses a JSON document with ArduinoJson. ```c++ -char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; +const char* json = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; JsonDocument doc; deserializeJson(doc, json); diff --git a/extras/scripts/wandbox/JsonGeneratorExample.cpp b/extras/scripts/wandbox/JsonGeneratorExample.cpp index 4e710986..a8d8323b 100644 --- a/extras/scripts/wandbox/JsonGeneratorExample.cpp +++ b/extras/scripts/wandbox/JsonGeneratorExample.cpp @@ -9,25 +9,18 @@ int main() { // Allocate the JSON document - // - // Inside the parentheses, 200 is the RAM allocated to this document. - // Don't forget to change this value to match your requirement. - // Use https://arduinojson.org/v6/assistant to compute the capacity. JsonDocument doc; - // Add values in the document - // + // Add values in the document. doc["sensor"] = "gps"; doc["time"] = 1351824120; - // Add an array. - // + // Add an array JsonArray data = doc["data"].to(); data.add(48.756080); data.add(2.302038); // Generate the minified JSON and send it to STDOUT - // serializeJson(doc, std::cout); // The above line prints: // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} @@ -36,7 +29,6 @@ int main() { std::cout << std::endl; // Generate the prettified JSON and send it to STDOUT - // serializeJsonPretty(doc, std::cout); // The above line prints: // { diff --git a/extras/scripts/wandbox/JsonParserExample.cpp b/extras/scripts/wandbox/JsonParserExample.cpp index d83d2e85..14f166f4 100644 --- a/extras/scripts/wandbox/JsonParserExample.cpp +++ b/extras/scripts/wandbox/JsonParserExample.cpp @@ -9,33 +9,22 @@ int main() { // Allocate the JSON document - // - // Inside the parentheses, 200 is the capacity of the memory pool in bytes. - // Don't forget to change this value to match your JSON document. - // Use https://arduinojson.org/v6/assistant to compute the capacity. JsonDocument doc; - // JSON input string. - // - // Using a char[], as shown here, enables the "zero-copy" mode. This mode uses - // the minimal amount of memory because the JsonDocument stores pointers to - // the input buffer. - // If you use another type of input, ArduinoJson must copy the strings from - // the input to the JsonDocument, so you need to increase the capacity of the - // JsonDocument. - char json[] = + // JSON input string + const char* json = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; // Deserialize the JSON document DeserializationError error = deserializeJson(doc, json); - // Test if parsing succeeds. + // Test if parsing succeeds if (error) { std::cerr << "deserializeJson() failed: " << error.c_str() << std::endl; return 1; } - // Fetch values. + // Fetch the values // // Most of the time, you can rely on the implicit casts. // In other case, you can do doc["time"].as(); @@ -44,7 +33,7 @@ int main() { double latitude = doc["data"][0]; double longitude = doc["data"][1]; - // Print values. + // Print the values std::cout << sensor << std::endl; std::cout << time << std::endl; std::cout << latitude << std::endl; diff --git a/extras/scripts/wandbox/MsgPackParserExample.cpp b/extras/scripts/wandbox/MsgPackParserExample.cpp index 605df763..6781e5c5 100644 --- a/extras/scripts/wandbox/MsgPackParserExample.cpp +++ b/extras/scripts/wandbox/MsgPackParserExample.cpp @@ -9,17 +9,9 @@ int main() { // Allocate the JSON document - // - // Inside the parentheses, 300 is the size of the memory pool in bytes. - // Don't forget to change this value to match your JSON document. - // Use https://arduinojson.org/assistant to compute the capacity. JsonDocument doc; - // MessagePack input string. - // - // It's better to use a char[] as shown here. - // If you use a const char* or a String, ArduinoJson will - // have to make a copy of the input in the JsonBuffer. + // The MessagePack input string 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, 97, 116, 97, 146, 203, 64, 72, 96, 199, 58, 188, 148, @@ -31,20 +23,16 @@ int main() { // "data": [48.75608, 2.302038] // } - // doc of the object tree. - // - // It's a reference to the JsonObject, the actual bytes are inside the - // JsonBuffer with all the other nodes of the object tree. - // Memory is freed when jsonBuffer goes out of scope. + // Parse the input DeserializationError error = deserializeMsgPack(doc, input); - // Test if parsing succeeds. + // Test if parsing succeeds if (error) { std::cerr << "deserializeMsgPack() failed: " << error.c_str() << std::endl; return 1; } - // Fetch values. + // Fetch the values // // Most of the time, you can rely on the implicit casts. // In other case, you can do doc["time"].as(); @@ -53,7 +41,7 @@ int main() { double latitude = doc["data"][0]; double longitude = doc["data"][1]; - // Print values. + // Print the values std::cout << sensor << std::endl; std::cout << time << std::endl; std::cout << latitude << std::endl; diff --git a/idf_component.yml b/idf_component.yml index 7bfd3992..77ed1e7d 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,7 +1,7 @@ version: "7.0.0-alpha" description: >- A simple and efficient JSON library for embedded C++. - ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ zero-copy, ✔ streams, ✔ filtering, and more. + ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation. url: https://arduinojson.org/ diff --git a/library.json b/library.json index c708220d..9d49ab99 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "ArduinoJson", "keywords": "json, rest, http, web", - "description": "A simple and efficient JSON library for embedded C++. ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ zero-copy, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation.", + "description": "A simple and efficient JSON library for embedded C++. ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation.", "homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json", "repository": { "type": "git", diff --git a/library.properties b/library.properties index 26278595..1e78910c 100644 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=7.0.0-alpha author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. -paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ zero-copy, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation. +paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation. category=Data Processing url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties architectures=*