Remove mentions of the zero-copy mode

This commit is contained in:
Benoit Blanchon
2023-08-19 16:05:04 +02:00
parent 51c5f1a73a
commit 7bd2ea1072
7 changed files with 16 additions and 48 deletions

View File

@ -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/) * [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 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 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) * [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/#filtering)
* Supports single quotes as a string delimiter * 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. Here is a program that parses a JSON document with ArduinoJson.
```c++ ```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; JsonDocument doc;
deserializeJson(doc, json); deserializeJson(doc, json);

View File

@ -9,25 +9,18 @@
int main() { int main() {
// Allocate the JSON document // 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; JsonDocument doc;
// Add values in the document // Add values in the document.
//
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 STDOUT // Generate the minified JSON and send it to STDOUT
//
serializeJson(doc, std::cout); serializeJson(doc, std::cout);
// 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]}
@ -36,7 +29,6 @@ int main() {
std::cout << std::endl; std::cout << std::endl;
// Generate the prettified JSON and send it to STDOUT // Generate the prettified JSON and send it to STDOUT
//
serializeJsonPretty(doc, std::cout); serializeJsonPretty(doc, std::cout);
// The above line prints: // The above line prints:
// { // {

View File

@ -9,33 +9,22 @@
int main() { int main() {
// Allocate the JSON document // 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; JsonDocument doc;
// JSON input string. // JSON input string
// const char* json =
// 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[] =
"{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
// 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) {
std::cerr << "deserializeJson() failed: " << error.c_str() << std::endl; std::cerr << "deserializeJson() failed: " << error.c_str() << std::endl;
return 1; return 1;
} }
// 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>();
@ -44,7 +33,7 @@ int main() {
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
std::cout << sensor << std::endl; std::cout << sensor << std::endl;
std::cout << time << std::endl; std::cout << time << std::endl;
std::cout << latitude << std::endl; std::cout << latitude << std::endl;

View File

@ -9,17 +9,9 @@
int main() { int main() {
// Allocate the JSON document // 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; JsonDocument doc;
// MessagePack input string. // The 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.
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,
@ -31,20 +23,16 @@ int main() {
// "data": [48.75608, 2.302038] // "data": [48.75608, 2.302038]
// } // }
// doc of the object tree. // Parse the input
//
// 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.
DeserializationError error = deserializeMsgPack(doc, input); DeserializationError error = deserializeMsgPack(doc, input);
// Test if parsing succeeds. // Test if parsing succeeds
if (error) { if (error) {
std::cerr << "deserializeMsgPack() failed: " << error.c_str() << std::endl; std::cerr << "deserializeMsgPack() failed: " << error.c_str() << std::endl;
return 1; return 1;
} }
// 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>();
@ -53,7 +41,7 @@ int main() {
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
std::cout << sensor << std::endl; std::cout << sensor << std::endl;
std::cout << time << std::endl; std::cout << time << std::endl;
std::cout << latitude << std::endl; std::cout << latitude << std::endl;

View File

@ -1,7 +1,7 @@
version: "7.0.0-alpha" version: "7.0.0-alpha"
description: >- description: >-
A simple and efficient JSON library for embedded C++. 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 ❤❤❤❤❤. It is the most popular Arduino library on GitHub ❤❤❤❤❤.
Check out arduinojson.org for a comprehensive documentation. Check out arduinojson.org for a comprehensive documentation.
url: https://arduinojson.org/ url: https://arduinojson.org/

View File

@ -1,7 +1,7 @@
{ {
"name": "ArduinoJson", "name": "ArduinoJson",
"keywords": "json, rest, http, web", "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", "homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -3,7 +3,7 @@ version=7.0.0-alpha
author=Benoit Blanchon <blog.benoitblanchon.fr> author=Benoit Blanchon <blog.benoitblanchon.fr>
maintainer=Benoit Blanchon <blog.benoitblanchon.fr> maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
sentence=A simple and efficient JSON library for embedded C++. 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 category=Data Processing
url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
architectures=* architectures=*